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 = 41
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 41
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 34
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 34
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 31
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 34
Branch analysis from position: 17
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
filename:       /in/dQ6eq
function name:  (null)
number of ops:  43
compiled vars:  !0 = $records, !1 = $X, !2 = $Y, !3 = $Z, !4 = $posLen, !5 = $pos, !6 = $len, !7 = $finalPos, !8 = $posArray, !9 = $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                                       $14     !0, ->41
          5    > > FE_FETCH_R                                               $14, !4, ->41
   30     6    >   FETCH_DIM_R                                      ~15     !4, 0
          7        ASSIGN                                                   !5, ~15
   31     8        FETCH_DIM_R                                      ~17     !4, 1
          9        ASSIGN                                                   !6, ~17
   35    10        INIT_FCALL                                               'is_numeric'
         11        SEND_VAR                                                 !6
         12        DO_ICALL                                         $19     
         13        BOOL_NOT                                         ~20     $19
         14      > JMPZ                                                     ~20, ->17
   36    15    >   FETCH_R                      local               ~21     !6
         16        ASSIGN                                                   !6, ~21
   39    17    >   ASSIGN                                                   !7, 0
   40    18        INIT_FCALL                                               'explode'
         19        SEND_VAL                                                 '%2B'
         20        SEND_VAR                                                 !5
         21        DO_ICALL                                         $24     
         22        ASSIGN                                                   !8, $24
   41    23      > FE_RESET_R                                       $26     !8, ->34
         24    > > FE_FETCH_R                                               $26, !9, ->34
   42    25    >   INIT_FCALL                                               'is_numeric'
         26        SEND_VAR                                                 !9
         27        DO_ICALL                                         $27     
         28      > JMPZ                                                     $27, ->31
   43    29    >   ASSIGN_OP                                     1          !7, !9
         30      > JMP                                                      ->33
   45    31    >   FETCH_R                      local               ~29     !9
         32        ASSIGN_OP                                     1          !7, ~29
   41    33    > > JMP                                                      ->24
         34    >   FE_FREE                                                  $26
   49    35        ROPE_INIT                                     3  ~32     !7
         36        ROPE_ADD                                      1  ~32     ~32, '%2C+'
         37        ROPE_END                                      2  ~31     ~32, !6
         38        CONCAT                                           ~34     ~31, '%0A'
         39        ECHO                                                     ~34
   29    40      > JMP                                                      ->5
         41    >   FE_FREE                                                  $14
   52    42      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
237.38 ms | 1400 KiB | 17 Q