Has anyone got any experience parsing the video id from youtube urls in php.
ie.
youtube.com/watch?v=R0BA-KviNO4&feature=related
Where the red is the part I want.
Has anyone got any experience parsing the video id from youtube urls in php.
ie.
youtube.com/watch?v=R0BA-KviNO4&feature=related
Where the red is the part I want.
what language ?
IT Books.ie | Computer Books
Recent Work | The Dropped.IE Domain List | Devine Building | Children's Festivals in Ireland | Galway Hot Yoga | Freelance Jobs African Safari Holiday
Blog | James Larkin Work | Web Design Dublin, Ireland - Web Development Dublin, Ireland
actually judging on your selfmade cms ...
I'll assume php ?
do a semi ok job for you ?Code:$string = "youtube.com/watch?v=R0BA-KviNO4&feature=related"; preg_match('/v\=(.+)&/',$string,$matches); echo $matches[1];
IT Books.ie | Computer Books
Recent Work | The Dropped.IE Domain List | Devine Building | Children's Festivals in Ireland | Galway Hot Yoga | Freelance Jobs African Safari Holiday
Blog | James Larkin Work | Web Design Dublin, Ireland - Web Development Dublin, Ireland
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.
seems to work well! I wrote it to a text file for include..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>";
cheers for your help..
Last edited by johned; 09-07-2008 at 04:13 PM.
ah fair enough I'd assumed it'd be part of a multiline post or something similar not just a URL you had
IT Books.ie | Computer Books
Recent Work | The Dropped.IE Domain List | Devine Building | Children's Festivals in Ireland | Galway Hot Yoga | Freelance Jobs African Safari Holiday
Blog | James Larkin Work | Web Design Dublin, Ireland - Web Development Dublin, Ireland
No probs just finished it now and i can use the form to send sizes etc to the embed code.. Just hope they dont change anything on there side now lol .