3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = <<<'EOT' <? $array = [ 'KEY_1' => 'VALUE_1', 'KEY_2' => 'VALUE_2', 'KEY_3' => 'VALUE_3', ]; EOT; $array = []; $key = null; $state = 0; foreach(token_get_all($str) as $token) { if(isset($token[0])) { if($token[0] === T_DOUBLE_ARROW) { $state = 1; } else if($token[0] === T_CONSTANT_ENCAPSED_STRING) { if($state === 0) { $key = substr($token[1], 1, -1); $state = 1; } else { $array[$key] = substr($token[1], 1, -1); $state = 0; } } } } var_dump($array);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 40
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 40
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 39
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 39
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 30
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 39
Branch analysis from position: 39
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
filename:       /in/Vrelq
function name:  (null)
number of ops:  45
compiled vars:  !0 = $str, !1 = $array, !2 = $key, !3 = $state, !4 = $token
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3C%3F%0A%24array+%3D+%5B%0A++++%27KEY_1%27+%3D%3E+%27VALUE_1%27%2C%0A++++%27KEY_2%27+%3D%3E+%27VALUE_2%27%2C%0A++++%27KEY_3%27+%3D%3E+%27VALUE_3%27%2C%0A%5D%3B'
   11     1        ASSIGN                                                   !1, <array>
   12     2        ASSIGN                                                   !2, null
   13     3        ASSIGN                                                   !3, 0
   15     4        INIT_FCALL                                               'token_get_all'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $9      
          7      > FE_RESET_R                                       $10     $9, ->40
          8    > > FE_FETCH_R                                               $10, !4, ->40
   17     9    >   ISSET_ISEMPTY_DIM_OBJ                         0          !4, 0
         10      > JMPZ                                                     ~11, ->39
   19    11    >   FETCH_DIM_R                                      ~12     !4, 0
         12        IS_IDENTICAL                                             ~12, 269
         13      > JMPZ                                                     ~13, ->16
   21    14    >   ASSIGN                                                   !3, 1
         15      > JMP                                                      ->39
   23    16    >   FETCH_DIM_R                                      ~15     !4, 0
         17        IS_IDENTICAL                                             ~15, 318
         18      > JMPZ                                                     ~16, ->39
   25    19    >   IS_IDENTICAL                                             !3, 0
         20      > JMPZ                                                     ~17, ->30
   27    21    >   INIT_FCALL                                               'substr'
         22        FETCH_DIM_R                                      ~18     !4, 1
         23        SEND_VAL                                                 ~18
         24        SEND_VAL                                                 1
         25        SEND_VAL                                                 -1
         26        DO_ICALL                                         $19     
         27        ASSIGN                                                   !2, $19
   28    28        ASSIGN                                                   !3, 1
         29      > JMP                                                      ->39
   32    30    >   INIT_FCALL                                               'substr'
         31        FETCH_DIM_R                                      ~23     !4, 1
         32        SEND_VAL                                                 ~23
         33        SEND_VAL                                                 1
         34        SEND_VAL                                                 -1
         35        DO_ICALL                                         $24     
         36        ASSIGN_DIM                                               !1, !2
         37        OP_DATA                                                  $24
   33    38        ASSIGN                                                   !3, 0
   15    39    > > JMP                                                      ->8
         40    >   FE_FREE                                                  $10
   39    41        INIT_FCALL                                               'var_dump'
         42        SEND_VAR                                                 !1
         43        DO_ICALL                                                 
         44      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.99 ms | 1405 KiB | 19 Q