Som Nicky skriver, så er det næsten ren søg og erstat.
- <?php
-
- $search = "!(http://.*youtube\.com.*v=)?([a-zA-Z0-9_-]{11})(&.*)?!";
-
- $youtube = '<object width="480" height="397"><param name="movie" value="http://www.youtube.com/v/\\2&ap=%2526fmt%3D18"></param><param name="wmode" value="transparent"></param>'
- .'<embed src="http://www.youtube.com/v/\\2&ap=%2526fmt%3D18" type="application/x-shockwave-flash" wmod="transparent" width="480" height="397"></embed></object>';
-
-
-
- $content = ' Blah blah tekst her http://www.youtube.com/watch?v=l119p8K25qA'."\n"
- .' og mere tekst her http://uk.youtube.com/watch?v=l119p8K25qA&blah=test&test=test og blah blah. ';
-
- echo $content = preg_replace($search, $youtube, $content);
-
- ?>