3v4l.org

run code in 500+ PHP versions simultaneously
<?php $input = [ ["relation" => "OR"], ["color" => 'green'], ["color" => 'yellow'], ["relation" => "AND"], ["color" => 'black'], ["color" => 'orange'], ["relation" => "OR"], ["color" => 'blue'], ["color" => 'violet'], ]; $ref = []; $result = &$ref; foreach ($input as $row) { if (key($row) !== 'relation') { // populate current level $ref[] = $row; continue; } if ($ref) { // not the first relation encountered $ref = &$ref[]; } $ref = $row; // store relation } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 18
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 18
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 16
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/Fhlkv
function name:  (null)
number of ops:  23
compiled vars:  !0 = $input, !1 = $ref, !2 = $result, !3 = $row
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   15     1        ASSIGN                                                       !1, <array>
   16     2        ASSIGN_REF                                                   !2, !1
   17     3      > FE_RESET_R                                           $7      !0, ->18
          4    > > FE_FETCH_R                                                   $7, !3, ->18
   18     5    >   INIT_FCALL                                                   'key'
          6        SEND_VAR                                                     !3
          7        DO_ICALL                                             $8      
          8        IS_NOT_IDENTICAL                                             $8, 'relation'
          9      > JMPZ                                                         ~9, ->13
   19    10    >   ASSIGN_DIM                                                   !1
         11        OP_DATA                                                      !3
   20    12      > JMP                                                          ->4
   22    13    > > JMPZ                                                         !1, ->16
   23    14    >   FETCH_DIM_W                                          $11     !1
         15        ASSIGN_REF                                                   !1, $11
   25    16    >   ASSIGN                                                       !1, !3
   17    17      > JMP                                                          ->4
         18    >   FE_FREE                                                      $7
   28    19        INIT_FCALL                                                   'var_export'
         20        SEND_VAR                                                     !2
         21        DO_ICALL                                                     
         22      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
163.2 ms | 1787 KiB | 14 Q