ohdang888 Posted December 12, 2009 Share Posted December 12, 2009 Alright, i want to take a url like this: http://www.youtube.com/watch?v=CVWvCJcse8w&feature=youtube_gdata and just get the ID of the video ( value of v) I've tried preg match, but i'm terrible figuring out the way those combination of letters are supposed to go. How would it go? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/184843-preg-match-confusion/ Share on other sites More sharing options...
rajivgonsalves Posted December 12, 2009 Share Posted December 12, 2009 you could do it in a simpler way <?php $str = 'http://www.youtube.com/watch?v=CVWvCJcse8w&feature=youtube_gdata'; $query = array(); $parts = parse_url($str); parse_str($parts['query'], $query); print_r($query); ?> Quote Link to comment https://forums.phpfreaks.com/topic/184843-preg-match-confusion/#findComment-975762 Share on other sites More sharing options...
cags Posted December 12, 2009 Share Posted December 12, 2009 Something like this should work... '#v=([a-z0-9]+)i' There's likely other tweaks that can be done, but that should work. Quote Link to comment https://forums.phpfreaks.com/topic/184843-preg-match-confusion/#findComment-975930 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.