gaza165 Posted August 21, 2008 Share Posted August 21, 2008 $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 More sharing options...
effigy Posted August 21, 2008 Share Posted August 21, 2008 What are you trying to do? What's the expected result? Link to comment https://forums.phpfreaks.com/topic/120692-why-wont-this-replace/#findComment-622096 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.