I'm building a blog that should parse bbcode tags like this:
Input: <youtube=http://www.youtube.com/watch?v=VIDEO_ID&feature=channel&gt;
Output:
<object width="400" height="245">
<param name="movie" value="http://www.youtube- nocookie.com/v/VIDEO_ID&hl=en&fs=1&rel=0&showinfo=0"></param>
<param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube-nocookie.com/v/VIDEO_ID&hl=en&fs=1&rel=0&showinfo=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="400" height="245"></embed>
</object>
My function is incredibly simple so far, because I've gotten stuck on the easiest part! Right now, I have a master process function that calls difference process functions. In this case one of them is processYouTubeVideos(). So I call it like so:
$str = eregi_replace('\<youtube=([^>]*)\>', processYouTubeVideos("\\1"), $str);
processYouTubeVideos() receives the URLs from inside the youtube tag perfectly, but for some reason, when using explode() (or split) the delimeter is never found. Even using test values like "u" or "tube"...
function processYouTubeVideos ($str) {
$params = explode("?", $str);
$params = explode("&", $params[1]);
return $params[0];
}
Thanks in advance for your help!