3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getYouTubeId($yturl) { $pattern = '~(?:http|https|)(?::\/\/|)(?:www.|)(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/ytscreeningroom\?v=|\/feeds\/api\/videos\/|\/user\S*[^\w\-\s]|\S*[^\w\-\s]))([\w\-]{11})[a-z0-9;:@?&%=+\/\$_.-]*~i'; return (preg_replace($pattern, '$1', $yturl)); } echo getYouTubeId("http://www.youtube.com/watch?v=OWjR8C8bKhQ");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AO0XV
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'getyoutubeid'
          1        SEND_VAL                                                 'http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DOWjR8C8bKhQ'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function getyoutubeid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AO0XV
function name:  getYouTubeId
number of ops:  9
compiled vars:  !0 = $yturl, !1 = $pattern
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, '%7E%28%3F%3Ahttp%7Chttps%7C%29%28%3F%3A%3A%5C%2F%5C%2F%7C%29%28%3F%3Awww.%7C%29%28%3F%3Ayoutu%5C.be%5C%2F%7Cyoutube%5C.com%28%3F%3A%5C%2Fembed%5C%2F%7C%5C%2Fv%5C%2F%7C%5C%2Fwatch%5C%3Fv%3D%7C%5C%2Fytscreeningroom%5C%3Fv%3D%7C%5C%2Ffeeds%5C%2Fapi%5C%2Fvideos%5C%2F%7C%5C%2Fuser%5CS%2A%5B%5E%5Cw%5C-%5Cs%5D%7C%5CS%2A%5B%5E%5Cw%5C-%5Cs%5D%29%29%28%5B%5Cw%5C-%5D%7B11%7D%29%5Ba-z0-9%3B%3A%40%3F%26%25%3D%2B%5C%2F%5C%24_.-%5D%2A%7Ei'
    6     2        INIT_FCALL                                               'preg_replace'
          3        SEND_VAR                                                 !1
          4        SEND_VAL                                                 '%241'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $3      
          7      > RETURN                                                   $3
    7     8*     > RETURN                                                   null

End of function getyoutubeid

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.86 ms | 1397 KiB | 16 Q