I am trying to write a php code, that checks if there is a certain word in the url and if so - show something.
I am using this one:
$url = parse_url($_SERVER['REQUEST_URI']);
if($url['path'] == '/main-category/') {
echo........
For example I am looking for "main-category". For http://www.site.com/main-category/ the code is working, but if the url contains subcategory http://www.site.com/main-category/sub-category/, it isn't.
How can I make it find /main-category/ no matter if there is something after it, or not?
I read some topics here but didn't figure it out.