<?php
$arr = array("<a href='url1'>name1</a>", "<a href=url2>name2</a>");
for ($j=0; $j<count($arr); $j++)
{
$str=$arr[$j];
}
$href = array("1.php", "2.php");
for ($i=0; $i<count($href); $i++)
{$hrefout = $href[$i];
$res = preg_replace("!<a.*?href=\"?'?([^ \"'>]+)\"?'?.*?>(.*?)</a>!is","<a href='".$hrefout."'>\\1</a>",$str);
echo"
<table>
<tr>Исходный код:
<td>".htmlspecialchars($res)."</td>
</tr>
</table>
";
}
?>
P.S. Заранее огромное спасибо за помощь)