View Single Post

  #4 (permalink)  
Old 09-07-2008, 04:09 PM
johned johned is offline
Coder
 
Join Date: Nov 2007
Posts: 75
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
johned will become famous soon enough
Default

I just cracked it without regular expressions from a little googling.

Here is the code it allows you to enter the url of a youtube vid in to a form and the code processes the form to parse the video id and insert it in to an embed code with preset values.

PHP Code:
//parse the id from the url
$url $_POST['id'];
$vidparser parse_url($url);
parse_str($vidparser[query], $query);
$vidid = ($query['v']);
 
 
//get the video id in to the embed code
$content "<object width=\"290\" height=\"235\"><param name=\"movie\" value=\"http://www.youtube.com/v/".$vidid."&hl=en&fs=1&rel=0\"></param><param name=\"allowFullScreen\" value=\"true\"></param><embed src=\"http://www.youtube.com/v/".$vidid."&hl=en&fs=1&rel=0\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" width=\"290\" height=\"235\"></embed></object>"
seems to work well! I wrote it to a text file for include..

cheers for your help..

Last edited by johned; 09-07-2008 at 04:13 PM.
Reply With Quote