$article = ('<p>In show business it is all about the extremes. For example the people
below earn a whole load of money thanks to their appearance and it is not at all
beautiful. They are some of the ugliest models but nevertheless they still work in
full swing. They get hired in movies, commercials, and anywhere where an ugly guy
(or a girl) is needed , and if you’re just plane average and you still wish to
work, well then you should probably do something extreme with your body like the
lizard man, for example.</p></a>
<a href="http://www.youtube.com/watch?v=eauCiY1MmZU">
http://www.youtube.com/watch?v=eauCiY1MmZU
</a>
function tubeCodeEmbed( $vCode ) {
return $vCode;
}
$search = '/\s*[a-zA-Z\/\/:\.]*youtube.com\/watch\?v=([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i';
$article = preg_replace($search, tubeCodeEmbed("$1"), $article);
echo $article;
This is what I have so far ..and it works except it does not strip hrefs from the string that have youtube in it.
My desired output
In show business it is all about the extremes. For example the people below earn a whole load of money thanks to their appearance and it is not at all beautiful. joeCiY1MmZU They are some of the ugliest models but nevertheless they still work in full swing. They get hired in movies, commercials, and anywhere where an ugly guy (or a girl) is needed , and if you’re just plane average and you still wish to work, well then you should probably do something extreme with your body like the lizard man, for example. oddCiY1MmZU eauCiY1MmZU
Notice the ID's in the output ...no url's or href tags from youtube