Jump to content

Why wont this replace??


gaza165

Recommended Posts

$url = "youtube.com/watch?v=Lf8w3nKzYaI";

$linkpattern = "/youtube\.com\/watch\?v=([A-Za-z0-9._%-]*)[&\w;=\+_\-]*/";
$linkmatch = preg_match_all($linkpattern, $url, $linkmatches);
$b = 0;	
print_r($linkmatches);
foreach($linkmatches[0] as $linkurl) {	
$replacement = "%LINK".$b."%";	
$url = preg_replace("@$linkurl@", $replacement, $url, 1);
$b++;
}

echo $url;

 

 

it prints the array ok, but just doesnt replace the string with the $replacement.

 

can anyone tell me why??

 

thanks

 

Garry

Link to comment
https://forums.phpfreaks.com/topic/120692-why-wont-this-replace/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.