Let's just say I have a simple text:
testing testing testing http://www.youtube.com/watch?v=pzfAdmAtYIY more testing and random text http://www.youtube.com/watch?v=UZQ_RDb0lcE more text etc
And I also have simple array:
$arr = array('Samsung Mobile USA - El Plato Supreme', 'SET FIRE | DUBSTEP');
How to achieve this:
testing testing testing pzfAdmAtYIY Samsung Mobile USA - El Plato Supreme more testing and random text UZQ_RDb0lcE SET FIRE | DUBSTEP more text etc
My attempt:
$count = 0;
$text = 'testing testing testing http://www.youtube.com/watch?v=pzfAdmAtYIY more testing and random text http://www.youtube.com/watch?v=UZQ_RDb0lcE more text etc';
$arr = array('Samsung Mobile USA - El Plato Supreme', 'SET FIRE | DUBSTEP');
$string = preg_replace('/http:\/\/www.youtube.com\/watch\?v=([a-zA-Z0-9_-]*)/ms', ' \\1 '. $arr[$count++].'', $text);
print $string;
Unforunately the result:
testing testing testing pzfAdmAtYIY Samsung Mobile USA - El Plato Supreme more testing and random text UZQ_RDb0lcE Samsung Mobile USA - El Plato Supreme more text etc
Any help would be great.