tags:

views:

41

answers:

2

For example I have a menu item named Categories and under that I have 10 different sub categories. So the url currently would be something like this:

http://domain/categories
http://domain/categories/sub1
http://domain/categories/sub2
...etc

I want to do something if the url is on categories regardless of what sub categories it is in. So instead of typing out each sub categories sub1, sub2...sub10..etc. How can I tell PHP to check if the URL is http://domain/categories/ and all sub after this...almost like an "ALL" wildcard...

+1  A: 

Well, there are a boatload of ways to do this. Here's one:

$a = strpos($var1, $var2)
if($a !== false) { ... }
dhorn
+2  A: 

The most simple (primitive) approach is:

if(substr_count($actual_url, 'http://domain/categories'))
{
    //do whatever you like
}
fabrik
Thanks, let me give that a go...
Rick
Could you accept my answer if it worked? :)
fabrik