3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function _getYoutubeVideoId($url) { $parts = parse_url($url); //For seriously malformed urls if ($parts === false) { return false; } switch ($parts['host']) { case 'youtu.be': return substr($parts['path'], 1); break; case 'youtube.com': case 'www.youtube.com': parse_str($parts['query'], $params); return $params['v']; break; default: return false; break; } } var_dump(_getYoutubeVideoId("http://www.youtube.com/watch?v=WQq0RAbj4i8"));
based on Ja14B
Output for 4.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
string(11) "WQq0RAbj4i8"
Output for hhvm-3.10.0

Process exited with code 153.