title: PHP Getting and Setting tag attributes
body: <p>im being played by php and DomDocument.... basically i have some html saved in db. With anchor tags with different urls.... i want to force anchor tag hrefs not within allowedurl list to be replaced with #</p>
  
  <p>eg</p>
  
  <pre><code>$allowed_url_basenames = array('viewprofile.php','viewalbum.php');
  </code></pre>
  
  <p>sample content from db1</p>
  
  <pre><code>&lt;table cellspacing="0" cellpadding="0"&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td valign="top"&gt;
              &lt;a href="viewprofile.php?userid=780"&gt;Edrine Kasasa &lt;/a&gt; has &amp;nbsp;
          &lt;/td&gt;
          &lt;td valign="top"&gt; 
          invited 10 friend(s) to veepiz using the &lt;a href="invite.php"&gt;Invite Tool&lt;/a&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
  </code></pre>
  
  <p></p>
  
  <p>i want a php function that will leave first anchor tag href intact and change the second to href='#'.</p>