Answer the question
In order to leave comments, you need to log in
How to compare url with string variable?
Hello!
Help solve this issue.
There is a variable to which a part of the url-address is passed. That is, for example, www.site.com/xxxx/. Where xxxx is what is being passed to the variable.
This variable must be compared with the URL of the page the user is on, and depending on this, display a specific message.
At the same time, so that if xxxx/yyyy is passed to the variable, it would display a message specific to yyyy, and not xxxx.
<?$pageurl = $APPLICATION->GetCurPage();?> //получаем урл страницы
<?if (preg_match($pages['PAGE'], $pageurl)):?> // если совпадают, что-то делаем...
....
<?endif;?>
Answer the question
In order to leave comments, you need to log in
You can get the last "fragment" from the url. For example like this:
$input = 'xxx/yyy/zzz';
$last_part = substr($input, 1 + strrpos($input, '/')); // zzz
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question