Determine last folder in URI / URL
<p>I am new to php and trying to return true / false based upon the user url. (Using this in drupal)
So for example if the user is at:</p>

<p><a href="http://www.example.com/training" rel="nofollow">http://www.example.com/training</a> I want it to return true</p>

<p><a href="http://www.example.com/training/home" rel="nofollow">http://www.example.com/training/home</a> I want it to return true</p>

<p><a href="http://www.example.com/browse/training/results/" rel="nofollow">http://www.example.com/browse/training/results/</a>* I want it to return true</p>

<p>For anything else though I want it false.</p>

<p><a href="http://www.example.com/training/backpacking" rel="nofollow">http://www.example.com/training/backpacking</a> I want it to return false.</p>

<p>My first ever php script has a bug...go figure. Anyway it doesn't show on anything that is not under training but it does show on training sub areas where it is not desired.</p>

<pre><code>global $language;
$curr_uri = check_plain(request_uri());

if ($language-&gt;language == 'en')
    if (basename(dirname($curr_uri)) == 'training')
        return TRUE;
    else
        return FALSE;
else
    return FALSE;
</code></pre>

<p>I understand the concept of what needs to be accomplished. I want to check for three specific uri's and not show on anything else. I also tried:</p>

<pre><code>global $language;
$curr_uri = check_plain(request_uri());

if ($language-&gt;language == 'en')
    if ($curr_uri == '/training/home')
        return TRUE;
    else
        return FALSE;
else
    return FALSE;
</code></pre>

<p>Adnan...I'm not sure what your edit was but I found a typo and it is working now with this code:</p>

<pre><code>&lt;?php
  global $language;
  $curr_uri = check_plain(request_uri());

if ( $language-&gt;language == 'en')
  if($curr_uri == '/training/home' || $curr_uri == '/browse/training/results' )
    return TRUE;
  else
    return FALSE;
else
  return FALSE;
?&gt;
</code></pre>
