3v4l.org

run code in 300+ PHP versions simultaneously
<?php $videoURLs = array( 'http://www.youtube.com/embed/VIDEO_ID', 'http://youtu.be/VIDEO_ID', 'http://www.youtube.com/v/VIDEO_ID', 'http://www.youtube.com/watch?v=VIDEO_ID', ); foreach ($videoURLs as $urlNow) { $url = parse_url($urlNow); $pathParts = explode('/', $url['path']); #$url['path'] = end($pathParts); $videoID = end($pathParts); #$videoID = $url['path']; if (isset($url['query'])) { parse_str($url['query'], $query); $videoID = $query['v']; } var_dump($urlNow, $videoID); } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 31
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 31
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 26
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 26
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/9u6Hb
function name:  (null)
number of ops:  33
compiled vars:  !0 = $videoURLs, !1 = $urlNow, !2 = $url, !3 = $pathParts, !4 = $videoID, !5 = $query
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    9     1      > FE_RESET_R                                       $7      !0, ->31
          2    > > FE_FETCH_R                                               $7, !1, ->31
   10     3    >   INIT_FCALL                                               'parse_url'
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $8      
          6        ASSIGN                                                   !2, $8
   11     7        INIT_FCALL                                               'explode'
          8        SEND_VAL                                                 '%2F'
          9        FETCH_DIM_R                                      ~10     !2, 'path'
         10        SEND_VAL                                                 ~10
         11        DO_ICALL                                         $11     
         12        ASSIGN                                                   !3, $11
   13    13        INIT_FCALL                                               'end'
         14        SEND_REF                                                 !3
         15        DO_ICALL                                         $13     
         16        ASSIGN                                                   !4, $13
   16    17        ISSET_ISEMPTY_DIM_OBJ                         0          !2, 'query'
         18      > JMPZ                                                     ~15, ->26
   17    19    >   INIT_FCALL                                               'parse_str'
         20        FETCH_DIM_R                                      ~16     !2, 'query'
         21        SEND_VAL                                                 ~16
         22        SEND_REF                                                 !5
         23        DO_ICALL                                                 
   18    24        FETCH_DIM_R                                      ~18     !5, 'v'
         25        ASSIGN                                                   !4, ~18
   21    26    >   INIT_FCALL                                               'var_dump'
         27        SEND_VAR                                                 !1
         28        SEND_VAR                                                 !4
         29        DO_ICALL                                                 
    9    30      > JMP                                                      ->2
         31    >   FE_FREE                                                  $7
   23    32      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
193.06 ms | 1401 KiB | 23 Q