3v4l.org

run code in 150+ 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(".youtube.com/embed/W-q0R_bj4i8"));
based on kM1th
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
string(11) "W-q0R_bj4i8"