3v4l.org

run code in 300+ PHP versions simultaneously
<?php function um_youtube_id_from_url($url) { $pattern = '%^# Match any youtube URL (?:https?://)? # Optional scheme. Either http or https (?:www\.)? # Optional www subdomain (?: # Group host alternatives youtu\.be/ # Either youtu.be, | youtube\.com # or youtube.com (?: # Group path alternatives /embed/ # Either /embed/ | /v/ # or /v/ | /watch\?v= # or /watch\?v= ) # End path alternatives. ) # End host alternatives. ([\w-]{10,12}) # Allow 10-12 for 11 char youtube id. $%x' ; $result = preg_match($pattern, $url, $matches); if (false !== $result) { return $matches[1]; } return false; } var_dump(um_youtube_id_from_url('<a href="https://www.youtube.com/watch?v=1aaXl4vaeJU">https://www.youtube.com/watch?v=1aaXl4vaeJU</a>')); var_dump(um_youtube_id_from_url("https://www.youtube.com/watch?v=1aaXl4vaeJU")); var_dump(um_youtube_id_from_url("https://www.youtube.com/v/1aaXl4vaeJU"));
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined array key 1 in /in/tKOvA on line 21 NULL string(11) "1aaXl4vaeJU" string(11) "1aaXl4vaeJU"

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
65.36 ms | 401 KiB | 8 Q