3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_converted_url($full_url) { $urls_to_convert = ['/some/url/', '/other/url']; $parsed_url = parse_url($full_url); $path = $parsed_url['path']; foreach ($urls_to_convert as $url_to_convert) { if (strpos($path, $url_to_convert, 0) !== false) { return $url_to_convert; } } return $path; } echo get_converted_url('/test/some/url/') . "\n"; echo get_converted_url('/some/url/a/b/') . "\n"; echo get_converted_url('/other/url/a/b/') . "\n"; echo get_converted_url('/strange/url/a/b/') . "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MSNCm
function name:  (null)
number of ops:  21
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'get_converted_url'
          1        SEND_VAL                                                 '%2Ftest%2Fsome%2Furl%2F'
          2        DO_FCALL                                      0  $0      
          3        CONCAT                                           ~1      $0, '%0A'
          4        ECHO                                                     ~1
   18     5        INIT_FCALL                                               'get_converted_url'
          6        SEND_VAL                                                 '%2Fsome%2Furl%2Fa%2Fb%2F'
          7        DO_FCALL                                      0  $2      
          8        CONCAT                                           ~3      $2, '%0A'
          9        ECHO                                                     ~3
   19    10        INIT_FCALL                                               'get_converted_url'
         11        SEND_VAL                                                 '%2Fother%2Furl%2Fa%2Fb%2F'
         12        DO_FCALL                                      0  $4      
         13        CONCAT                                           ~5      $4, '%0A'
         14        ECHO                                                     ~5
   20    15        INIT_FCALL                                               'get_converted_url'
         16        SEND_VAL                                                 '%2Fstrange%2Furl%2Fa%2Fb%2F'
         17        DO_FCALL                                      0  $6      
         18        CONCAT                                           ~7      $6, '%0A'
         19        ECHO                                                     ~7
         20      > RETURN                                                   1

Function get_converted_url:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 20
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 20
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/MSNCm
function name:  get_converted_url
number of ops:  23
compiled vars:  !0 = $full_url, !1 = $urls_to_convert, !2 = $parsed_url, !3 = $path, !4 = $url_to_convert
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, <array>
    6     2        INIT_FCALL                                               'parse_url'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $6      
          5        ASSIGN                                                   !2, $6
    7     6        FETCH_DIM_R                                      ~8      !2, 'path'
          7        ASSIGN                                                   !3, ~8
    8     8      > FE_RESET_R                                       $10     !1, ->20
          9    > > FE_FETCH_R                                               $10, !4, ->20
    9    10    >   INIT_FCALL                                               'strpos'
         11        SEND_VAR                                                 !3
         12        SEND_VAR                                                 !4
         13        SEND_VAL                                                 0
         14        DO_ICALL                                         $11     
         15        TYPE_CHECK                                  1018          $11
         16      > JMPZ                                                     ~12, ->19
   10    17    >   FE_FREE                                                  $10
         18      > RETURN                                                   !4
    8    19    > > JMP                                                      ->9
         20    >   FE_FREE                                                  $10
   13    21      > RETURN                                                   !3
   14    22*     > RETURN                                                   null

End of function get_converted_url

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
197.74 ms | 1010 KiB | 19 Q