Using preg_match on my nav to add active state
<p>I'm not too good with php, just the basics. So i'm using php to add the active states to my navigation links and using css after to style them, I was wondering if theres a way to use hashtags. I have two different navigation links that are both on one page. The first one works fine because no # is used but the second since the info for that page is on the same page as the default, I have the following code:</p>

<pre><code>&lt;?php
if (preg_match ("//", $_SERVER['REQUEST_URI'])){ $navID = "home";} 
if (preg_match ("/service-area/", $_SERVER['REQUEST_URI'])){ $navID = "service";} 
if (preg_match ("/about/", $_SERVER['REQUEST_URI'])){ $navID = "about";} 
    if (preg_match ("/heating-air/", $_SERVER['REQUEST_URI'])){ $navID = "heating";} 
if (preg_match ("/plumbing-hvac/", $_SERVER['REQUEST_URI'])){ $navID = "plumbing";} 
?&gt;
</code></pre>

<p>Theres the pregmatch and here are the links:</p>

<pre><code>&lt;ul class="right-nav"&gt;
            &lt;li class="heating-air"&gt;&lt;a href="/plumbing-hvac/#heating-air" &lt;?= ($navID == 'heating') ? ' class="active"' : '' ?&gt;&gt;Plumbing&lt;/a&gt;&lt;/li&gt;   
            &lt;li class="plumbing"&gt;&lt;a href="/plumbing-hvac/" &lt;?= ($navID == 'plumbing') ? ' class="active"' : '' ?&gt;&gt;Heating &amp;amp; Air&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
</code></pre>

<p>I get an error whenever I add the anchor link to the <code>preg_match()</code> section. Is there a way around this?</p>
