hey guys,
I’m a preg_replace noob and don’t understand how to solve the following case:
$youtubeurl = "((http|https)\:\/\/(www|it|co\.uk|ie|br|pl|jp|fr|es|nl|de)\.youtube\.(com|it|co\.uk|ie|br|pl|jp|fr|es|nl|de)([a-zA-Z0-9\-\.\/\?_=&;]*))";
$content = preg_replace($youtubeurl, embedCode($youtubeurl), $content);
I have a pattern that matches any youtube URL.
If this pattern is matched i want to call the function embedCode() and pass along the matched string.
How can i do this. right now i’m obviously passing along the regexp code which is of course wrong. I need to pass along the matched string.
thank you
Try preg_replace_callback.