Current menu item - foreach
<p>Consider this: </p>

<pre><code>    $menuItems = array (
        "page1" =&gt; "1.php",
        "page2" =&gt; "2.php",
        "page3" =&gt; "3.php",
        "page4" =&gt; "4.php",
        "page5" =&gt; "5.php",
     );
</code></pre>

<p>and now I create the menu like this:</p>

<pre><code>    &lt;ul class="menu"&gt;
        &lt;?php 
           foreach($menuItems as $name =&gt; $url) {
           echo "&lt;li&gt;&lt;a href='$url' class='$class'&gt;$name&lt;/a&gt;&lt;/li&gt;";
           } 
        ?&gt;
    &lt;/ul&gt;
</code></pre>

<p>Works great. But now I need to add a class .current on the current page.</p>

<p>To get the current page I do this:</p>

<pre><code>      &lt;?php 
         function curPageName() {
            return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
         }
         $curpage = curPageName();
      ?&gt;
</code></pre>

<p>And it also works great.</p>

<p>SO I guess the question is how do I assign $curpage to the ... current page? :)</p>

<p>Thank you.
Alex</p>
