regex change me the result of preg_replace_callback
Posted: Sat Oct 28, 2006 11:29 am
for example
It work perfectly, but....
# The problem is that return me the last match like $a2´s content, and not all content with some changes. Why?
This last print me that $a2´s content is and not

Code: Select all
$a2=" <a href=http://holaaaa something=value> <link href=' hola che!' boder> ";
function change($aver)
{
return strtoupper($aver[0]);
}
echo preg_replace_callback("/[a]*/is","change",$a2);Code: Select all
$a2=" <a href=http://holaaaa something=value> <link href=' hola che!' boder> ";
function ech($aver)
{
if($aver[1]{0}!='\'' && $aver[1]{0}!='"')
$av=str_replace($aver[1],'"'.$aver[1].'"',$aver[0]);
return $av;
}
$z2='/<\s*[a-z:-]+\s+.*?\s*href\s*=\s*(?:'.'([\'"`])(.*?)\\1|([^\s]+))[^>]*>/is';
echo preg_replace_callback($z2,"ech",$a2);This last print me that $a2´s content is
Code: Select all
<link href=' hola che!' boder>Code: Select all
<a href="http://holaaaa" something=value> <link href=' hola che!' boder>