fluxadd Posted September 17, 2011 Share Posted September 17, 2011 hello, I want to extract a youtube video variable from users comments, i make a simple function but it works just for one url, if they posted more urls in the same comment, it will return just the first video. this is what i've done before now: function get_youtube ($youtube){ $findme = 'youtube.com/watch?v='; $pos = strpos($youtube, $findme); if ($pos !== false) { parse_str( parse_url( $youtube, PHP_URL_QUERY )); echo $v; } } How can I make to extract all the $v from a comment with more url? THX Quote Link to comment https://forums.phpfreaks.com/topic/247329-extract-youtubecom-variables-from-a-comment/ Share on other sites More sharing options...
doddsey_65 Posted September 17, 2011 Share Posted September 17, 2011 you will need to use preg_match_all which will save all of the matches into an array. you can the display each video that appears in the array. Quote Link to comment https://forums.phpfreaks.com/topic/247329-extract-youtubecom-variables-from-a-comment/#findComment-1270227 Share on other sites More sharing options...
QuickOldCar Posted September 17, 2011 Share Posted September 17, 2011 Take a look at this post http://www.phpfreaks.com/forums/index.php?topic=342974.msg1619535#msg1619535 Quote Link to comment https://forums.phpfreaks.com/topic/247329-extract-youtubecom-variables-from-a-comment/#findComment-1270240 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.