3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function parse_yturl($url) { $tmp = explode('?v=', $url); $tmp[0] == $url && ($tmp = explode('&v=', $url)); if ($tmp[0] == $url) { return false; } else { $tmp = explode('&', $tmp[1]); return $tmp[0]; } } echo parse_yturl("https://m.youtube.com/watch?v=p-e2G_VcTms&feature=g-logo&context=G29aead6FOAAAAAAABAA") . PHP_EOL; echo parse_yturl("https://www.youtube.com/watch?v=p-e2G_VcTms") . PHP_EOL; echo parse_yturl("http://youtube.com/watch?feature=g-logo&v=p-e2G_VcTms&context=G29aead6FOAAAAAAABAA");
based on tH1MG
Output for 4.3.10 - 4.4.9, 5.0.2 - 7.1.0
p-e2G_VcTms p-e2G_VcTms p-e2G_VcTms
Output for 4.3.0 - 4.3.9, 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/TpP95 on line 16 p-e2G_VcTmsPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/TpP95 on line 17 p-e2G_VcTmsPHP_EOLp-e2G_VcTms