3v4l.org

run code in 300+ PHP versions simultaneously
<?php $levels = ['country','state','city','location']; $locations = [ ['country'=>'USA', 'state'=>'New York', 'city'=>'NYC', 'location'=>'Central Park', 'street'=>'7th Ave', 'count'=>123], ['country'=>'USA', 'state'=>'Maryland', 'city'=>'Baltimore', 'location'=>'Harber', 'count'=>24], ['country'=>'USA', 'state'=>'Michigan', 'city'=>'Lansing', 'location'=>'Midtown', 'building'=>'H2B', 'count'=>7], ['country'=>'France', 'state'=>'Sud', 'city'=>'Marseille', 'location'=>'Centre Ville', 'count'=>12], ]; $output = []; foreach($locations as $loc){ $str_to_eval='$output'; for($i=0;$i<count($levels);$i++){ $str_to_eval .= "[\$loc[\$levels[$i]]]"; } $str_to_eval .= "=\$loc['count'];"; eval($str_to_eval); } print_r($output);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 19
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 19
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 8
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 8
Branch analysis from position: 16
Branch analysis from position: 8
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/1vFD8
function name:  (null)
number of ops:  24
compiled vars:  !0 = $levels, !1 = $locations, !2 = $output, !3 = $loc, !4 = $str_to_eval, !5 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        ASSIGN                                                   !1, <array>
    9     2        ASSIGN                                                   !2, <array>
   10     3      > FE_RESET_R                                       $9      !1, ->19
          4    > > FE_FETCH_R                                               $9, !3, ->19
   11     5    >   ASSIGN                                                   !4, '%24output'
   12     6        ASSIGN                                                   !5, 0
          7      > JMP                                                      ->13
   13     8    >   ROPE_INIT                                     3  ~13     '%5B%24loc%5B%24levels%5B'
          9        ROPE_ADD                                      1  ~13     ~13, !5
         10        ROPE_END                                      2  ~12     ~13, '%5D%5D%5D'
         11        ASSIGN_OP                                     8          !4, ~12
   12    12        PRE_INC                                                  !5
         13    >   COUNT                                            ~17     !0
         14        IS_SMALLER                                               !5, ~17
         15      > JMPNZ                                                    ~18, ->8
   15    16    >   ASSIGN_OP                                     8          !4, '%3D%24loc%5B%27count%27%5D%3B'
   16    17        INCLUDE_OR_EVAL                                          !4, EVAL
   10    18      > JMP                                                      ->4
         19    >   FE_FREE                                                  $9
   18    20        INIT_FCALL                                               'print_r'
         21        SEND_VAR                                                 !2
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.38 ms | 999 KiB | 14 Q