3v4l.org

run code in 300+ PHP versions simultaneously
<?php $records = [ ['1', '2'], ['3', '9'], ['12', '8' ], ['20', '2' ], ['22', '15' ], ['37', '16' ], ['53', '16' ], ['69', '16' ], ['85', '1' ], ['86', '4' ], ['90', '4' ], ['94', '4' ], ['98', '4' ], ['102', '4', '5' ], ['106+X', 'X'], ['106+X', '5', '10'], ['111+X', 'Y'], ['111+X+Y', '7', '20'], ['118+X+Y', 'Z'], ]; $X = 10; $Y = 15; $Z = 5; foreach ($records as $posLen) { $pos = $posLen[0]; $len = $posLen[1]; $val = $posLen[2]; // if $len is a character, then it represents a variable. if (!is_numeric($len)) { $len = $$len; } $finalPos = 0; $posArray = explode('+', $pos); foreach($posArray as $posItem) { if (is_numeric($posItem)) { $finalPos += $posItem; } else { $finalPos += $$posItem; } } echo "$finalPos, $len" . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 43
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 43
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
2 jumps found. (Code = 77) Position 1 = 26, Position 2 = 36
Branch analysis from position: 26
2 jumps found. (Code = 78) Position 1 = 27, Position 2 = 36
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 33
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 36
Branch analysis from position: 19
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
filename:       /in/VtTOQ
function name:  (null)
number of ops:  45
compiled vars:  !0 = $records, !1 = $X, !2 = $Y, !3 = $Z, !4 = $posLen, !5 = $pos, !6 = $len, !7 = $val, !8 = $finalPos, !9 = $posArray, !10 = $posItem
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   25     1        ASSIGN                                                   !1, 10
   26     2        ASSIGN                                                   !2, 15
   27     3        ASSIGN                                                   !3, 5
   29     4      > FE_RESET_R                                       $15     !0, ->43
          5    > > FE_FETCH_R                                               $15, !4, ->43
   30     6    >   FETCH_DIM_R                                      ~16     !4, 0
          7        ASSIGN                                                   !5, ~16
   31     8        FETCH_DIM_R                                      ~18     !4, 1
          9        ASSIGN                                                   !6, ~18
   32    10        FETCH_DIM_R                                      ~20     !4, 2
         11        ASSIGN                                                   !7, ~20
   35    12        INIT_FCALL                                               'is_numeric'
         13        SEND_VAR                                                 !6
         14        DO_ICALL                                         $22     
         15        BOOL_NOT                                         ~23     $22
         16      > JMPZ                                                     ~23, ->19
   36    17    >   FETCH_R                      local               ~24     !6
         18        ASSIGN                                                   !6, ~24
   39    19    >   ASSIGN                                                   !8, 0
   40    20        INIT_FCALL                                               'explode'
         21        SEND_VAL                                                 '%2B'
         22        SEND_VAR                                                 !5
         23        DO_ICALL                                         $27     
         24        ASSIGN                                                   !9, $27
   41    25      > FE_RESET_R                                       $29     !9, ->36
         26    > > FE_FETCH_R                                               $29, !10, ->36
   42    27    >   INIT_FCALL                                               'is_numeric'
         28        SEND_VAR                                                 !10
         29        DO_ICALL                                         $30     
         30      > JMPZ                                                     $30, ->33
   43    31    >   ASSIGN_OP                                     1          !8, !10
         32      > JMP                                                      ->35
   45    33    >   FETCH_R                      local               ~32     !10
         34        ASSIGN_OP                                     1          !8, ~32
   41    35    > > JMP                                                      ->26
         36    >   FE_FREE                                                  $29
   49    37        ROPE_INIT                                     3  ~35     !8
         38        ROPE_ADD                                      1  ~35     ~35, '%2C+'
         39        ROPE_END                                      2  ~34     ~35, !6
         40        CONCAT                                           ~37     ~34, '%0A'
         41        ECHO                                                     ~37
   29    42      > JMP                                                      ->5
         43    >   FE_FREE                                                  $15
   52    44      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.1 ms | 1400 KiB | 17 Q