Page 2 of 2

Posted: Sat Oct 28, 2006 10:46 am
by visonardo
sorry by insist but now i have a secundary problem :?

for example

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);
It work perfectly, but....


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);
# The problem is that return me the last match like $a2´s content, and not all content with some changes. Why? 8O

This last print me that $a2´s content is

Code: Select all

<link href=' hola che!' boder>
and not

Code: Select all

<a href="http://holaaaa" something=value>      <link href=' hola che!' boder>
:?

Posted: Sat Oct 28, 2006 3:37 pm
by feyd
I'm having a tough time trying to figure out what you're trying to do... It looks like you want to add quotes around the url's that don't have them, in which case you'll be working with the third element of the array given to ech().

Posted: Sun Oct 29, 2006 1:27 pm
by visonardo
thank feyd :wink: