jwk811 Posted May 27, 2009 Share Posted May 27, 2009 youtube url looks like this how can i just get gUPduAbJpsU, i just want the "v" variable. Link to comment https://forums.phpfreaks.com/topic/159942-get-variables-from-string-url/ Share on other sites More sharing options...
redarrow Posted May 27, 2009 Share Posted May 27, 2009 <?php $url="http://www.youtube.com/watch?v=gUPduAbJpsU&videos=HsyjHLxVbwo&playnext_from=TL&playnext=1"; preg_match("/[v]\=[a-z].{0,200}/",$url,$match); print_R($match); ?> Link to comment https://forums.phpfreaks.com/topic/159942-get-variables-from-string-url/#findComment-843548 Share on other sites More sharing options...
redarrow Posted May 27, 2009 Share Posted May 27, 2009 <?php $url="http://www.youtube.com/watch?v=gUPduAbJpsU&videos=HsyjHLxVbwo&playnext_from=TL&playnext=1"; preg_match("/[v]\=[a-zA-Z]{0,20}/",$url,$match); print_R($match); ?> readable way <?php $url="http://www.youtube.com/watch?v=gUPduAbJpsU&videos=HsyjHLxVbwo&playnext_from=TL&playnext=1"; preg_match("/[v]\=[a-zA-Z]{0,20}/",$url,$match); $result=implode(' ',$match); echo $result; ?> Link to comment https://forums.phpfreaks.com/topic/159942-get-variables-from-string-url/#findComment-843553 Share on other sites More sharing options...
jwk811 Posted May 27, 2009 Author Share Posted May 27, 2009 thank you! one thing it says v=gUPduAbJpsU can i just get gUPduAbJpsU without the v=? Link to comment https://forums.phpfreaks.com/topic/159942-get-variables-from-string-url/#findComment-843561 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.