3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_tracking_url($tracking_number) { $php_tracking_urls = array( array( 'url'=>'http://wwwapps.ups.com/WebTracking/processInputRequest?TypeOfInquiryNumber=T&InquiryNumber1=', 'reg'=>'/\b(1Z ?[0-9A-Z]{3} ?[0-9A-Z]{3} ?[0-9A-Z]{2} ?[0-9A-Z]{4} ?[0-9A-Z]{3} ?[0-9A-Z]|[\dT]\d\d\d ?\d\d\d\d ?\d\d\d)\b/i' ), array( 'url'=>'https://tools.usps.com/go/TrackConfirmAction?qtc_tLabels1=', 'reg'=>'/\b((420 ?\d\d\d\d\d ?)?(91|94|01|03|04|70|23|13)\d\d ?\d\d\d\d ?\d\d\d\d ?\d\d\d\d ?\d\d\d\d( ?\d\d)?)\b/i' ), array( 'url'=>'https://tools.usps.com/go/TrackConfirmAction?qtc_tLabels1=', 'reg'=>'/\b((M|P[A-Z]?|D[C-Z]|LK|EA|V[A-Z]|R[A-Z]|CP|CJ|LC|LJ) ?\d\d\d ?\d\d\d ?\d\d\d ?[A-Z]?[A-Z]?)\b/i' ), array( 'url'=>'http://www.fedex.com/Tracking?language=english&cntry_code=us&tracknumbers=', 'reg'=>'/\b((96\d\d\d\d\d ?\d\d\d\d|96\d\d|\d\d\d\d) ?\d\d\d\d ?\d\d\d\d( ?\d\d\d)?)\b/i' ), array( 'url'=>'http://www.ontrac.com/trackres.asp?tracking_number=', 'reg'=>'/\b(C\d\d\d\d\d\d\d\d\d\d\d\d\d\d)\b/i' ), ); foreach ($php_tracking_urls as $item) { $match = array(); preg_match($item['reg'], $tracking_number, $match); if (count($match)) return $item['url'] . $match[0]; } return false; } var_dump(get_tracking_url('1Z0ER5190360727519')); var_dump(get_tracking_url('504098696310')); var_dump(get_tracking_url('9241996901177419132227'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BpG14
function name:  (null)
number of ops:  19
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'get_tracking_url'
          2        SEND_VAL                                                 '1Z0ER5190360727519'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
   34     6        INIT_FCALL                                               'var_dump'
          7        INIT_FCALL                                               'get_tracking_url'
          8        SEND_VAL                                                 '504098696310'
          9        DO_FCALL                                      0  $2      
         10        SEND_VAR                                                 $2
         11        DO_ICALL                                                 
   35    12        INIT_FCALL                                               'var_dump'
         13        INIT_FCALL                                               'get_tracking_url'
         14        SEND_VAL                                                 '9241996901177419132227'
         15        DO_FCALL                                      0  $4      
         16        SEND_VAR                                                 $4
         17        DO_ICALL                                                 
         18      > RETURN                                                   1

Function get_tracking_url:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 19
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 19
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 18
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/BpG14
function name:  get_tracking_url
number of ops:  22
compiled vars:  !0 = $tracking_number, !1 = $php_tracking_urls, !2 = $item, !3 = $match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                                   !1, <array>
   26     2      > FE_RESET_R                                       $5      !1, ->19
          3    > > FE_FETCH_R                                               $5, !2, ->19
   27     4    >   ASSIGN                                                   !3, <array>
   28     5        INIT_FCALL                                               'preg_match'
          6        FETCH_DIM_R                                      ~7      !2, 'reg'
          7        SEND_VAL                                                 ~7
          8        SEND_VAR                                                 !0
          9        SEND_REF                                                 !3
         10        DO_ICALL                                                 
   29    11        COUNT                                            ~9      !3
         12      > JMPZ                                                     ~9, ->18
         13    >   FETCH_DIM_R                                      ~10     !2, 'url'
         14        FETCH_DIM_R                                      ~11     !3, 0
         15        CONCAT                                           ~12     ~10, ~11
         16        FE_FREE                                                  $5
         17      > RETURN                                                   ~12
   26    18    > > JMP                                                      ->3
         19    >   FE_FREE                                                  $5
   31    20      > RETURN                                                   <false>
   32    21*     > RETURN                                                   null

End of function get_tracking_url

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.74 ms | 1403 KiB | 20 Q