3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function _getYoutubeVideoId($url) { if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $url, $match)) { return $match[1]; } } var_dump(_getYoutubeVideoId("http://www.youtube.com/watch?v=U0Yh08JnOZE"));
based on aeAbc
Output for 4.3.0 - 7.2.0
string(11) "U0Yh08JnOZE"