Find link element by URL and add a class using PHP
<p>I'm trying to add a class to the current item using PHP. I have a static navigation that looks like this:</p>

<pre><code>&lt;ul id="myList"&gt;
  &lt;li&gt;&lt;a href="page1.php"&gt;Page One&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="page2.php"&gt;Page Two&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="page3.php"&gt;Page Three&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</code></pre>

<p>The logic I want to follow is:</p>

<ol>
<li>Grab the URL and get the last section, store it in a <code>$path</code> variable.</li>
<li>Find a link from within <code>myList</code> that has the SRC attribute that matches <code>$path</code></li>
<li>Add a class of <code>.current</code> to the attribute.</li>
</ol>

<p>I've already sorted point one with this:</p>

<pre><code>$path = basename( parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) );
</code></pre>

<p>But I'm new to PHP so I'm not sure how to go about points 2 &amp; 3. Please help!</p>
