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 #
eg
$allowed_url_basenames = array('viewprofile.php','viewalbum.php');
sample content from db1
<table cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top">
<a href="viewprofile.php?userid=780">Edrine Kasasa </a> has
</td>
<td valign="top">
invited 10 friend(s) to veepiz using the <a href="invite.php">Invite Tool</a>
</td>
</tr>
</tbody>
i want a php function that will leave first anchor tag href intact and change the second to href='#'.