Check for certain word in the URL with PHP
<p>I am trying to write a php code, that checks if there is a certain word in the url and if so - show something.</p>

<p>I am using this one:</p>

<pre><code>$url = parse_url($_SERVER['REQUEST_URI']);

if($url['path'] == '/main-category/') {
echo........
</code></pre>

<p>For example I am looking for "main-category". For <a href="http://www.site.com/main-category/" rel="nofollow">http://www.site.com/main-category/</a> the code is working, but if the url contains subcategory <a href="http://www.site.com/main-category/sub-category/" rel="nofollow">http://www.site.com/main-category/sub-category/</a>, it isn't.</p>

<p>How can I make it find /main-category/ no matter if there is something after it, or not?</p>

<p>I read some topics here but didn't figure it out.</p>
