3v4l.org

run code in 300+ PHP versions simultaneously
<?php function parse_yturl($url) { $pattern = '#^(?:https?://)?(?:www|m\.)?(?:youtu\.be/|youtube\.com(?:/embed/|/v/|/watch\?v=|/watch\?.+&v=))([\w-]{11})(?:.+)?$#x'; preg_match($pattern, $url, $matches); return (isset($matches[1])) ? $matches[1] : false; } $url1 = "http://www.youtu.be/p-e2G_VcTms"; $url2 = "https://m.youtube.com/watch?v=p-e2G_VcTms&feature=g-logo&context=G29aead6FOAAAAAAABAA"; $url3 = "https://www.youtube.com/latest"; $vIds = array( parse_yturl($url1), parse_yturl($url2), parse_yturl($url3), ); var_dump($vIds);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/W3qqF
function name:  (null)
number of ops:  20
compiled vars:  !0 = $url1, !1 = $url2, !2 = $url3, !3 = $vIds
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   ASSIGN                                                   !0, 'http%3A%2F%2Fwww.youtu.be%2Fp-e2G_VcTms'
   11     1        ASSIGN                                                   !1, 'https%3A%2F%2Fm.youtube.com%2Fwatch%3Fv%3Dp-e2G_VcTms%26feature%3Dg-logo%26context%3DG29aead6FOAAAAAAABAA'
   12     2        ASSIGN                                                   !2, 'https%3A%2F%2Fwww.youtube.com%2Flatest'
   15     3        INIT_FCALL                                               'parse_yturl'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0  $7      
          6        INIT_ARRAY                                       ~8      $7
   16     7        INIT_FCALL                                               'parse_yturl'
          8        SEND_VAR                                                 !1
          9        DO_FCALL                                      0  $9      
         10        ADD_ARRAY_ELEMENT                                ~8      $9
   17    11        INIT_FCALL                                               'parse_yturl'
         12        SEND_VAR                                                 !2
         13        DO_FCALL                                      0  $10     
         14        ADD_ARRAY_ELEMENT                                ~8      $10
   14    15        ASSIGN                                                   !3, ~8
   20    16        INIT_FCALL                                               'var_dump'
         17        SEND_VAR                                                 !3
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

Function parse_yturl:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/W3qqF
function name:  parse_yturl
number of ops:  15
compiled vars:  !0 = $url, !1 = $pattern, !2 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, '%23%5E%28%3F%3Ahttps%3F%3A%2F%2F%29%3F%28%3F%3Awww%7Cm%5C.%29%3F%28%3F%3Ayoutu%5C.be%2F%7Cyoutube%5C.com%28%3F%3A%2Fembed%2F%7C%2Fv%2F%7C%2Fwatch%5C%3Fv%3D%7C%2Fwatch%5C%3F.%2B%26v%3D%29%29%28%5B%5Cw-%5D%7B11%7D%29%28%3F%3A.%2B%29%3F%24%23x'
    6     2        INIT_FCALL                                               'preg_match'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        SEND_REF                                                 !2
          6        DO_ICALL                                                 
    7     7        ISSET_ISEMPTY_DIM_OBJ                         0          !2, 1
          8      > JMPZ                                                     ~5, ->12
          9    >   FETCH_DIM_R                                      ~6      !2, 1
         10        QM_ASSIGN                                        ~7      ~6
         11      > JMP                                                      ->13
         12    >   QM_ASSIGN                                        ~7      <false>
         13    > > RETURN                                                   ~7
    8    14*     > RETURN                                                   null

End of function parse_yturl

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.37 ms | 1403 KiB | 20 Q