3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( 98 => array( 'City' => 'Caracas', 'Country' => 'Venezuela', 'Continent' => 'Latin America', ), 99 => array( 'City' => 'Cairo', 'Country' => 'Egypt', 'Continent' => 'Middle East', ), 105 => array( 'City' => 'Abu Dhabi', 'Country' => 'United Arab Emirates', 'Continent' => 'Middle East', ), 106 => array( 'City' => 'Dubai', 'Country' => 'United Arab Emirates', 'Continent' => 'Middle East', ), 107 => array( 'City' => 'Montreal', 'Country' => 'Canada', 'Continent' => 'North America', ) ); $result = []; foreach ( $array as [ 'Continent' => $a, 'Country' => $b, 'City' => $result[$a][$b][] ] ); var_export( array_reduce( $array, function($result, $row) { $result[$row['Continent']][$row['Country']][] = $row['City']; return $result; } ) );
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 15
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 15
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/d7n8V
function name:  (null)
number of ops:  25
compiled vars:  !0 = $array, !1 = $result, !2 = $a, !3 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   31     1        ASSIGN                                                   !1, <array>
   33     2      > FE_RESET_R                                       $6      !0, ->15
          3    > > FE_FETCH_R                                               $6, $7, ->15
   35     4    >   FETCH_LIST_R                                     $8      $7, 'Continent'
          5        ASSIGN                                                   !2, $8
   36     6        FETCH_LIST_R                                     $10     $7, 'Country'
          7        ASSIGN                                                   !3, $10
   37     8        FETCH_LIST_R                                     $12     $7, 'City'
          9        FETCH_DIM_W                                      $13     !1, !2
         10        FETCH_DIM_W                                      $14     $13, !3
         11        ASSIGN_DIM                                               $14
         12        OP_DATA                                                  $12
         13        FREE                                                     $7
   33    14      > JMP                                                      ->3
         15    >   FE_FREE                                                  $6
   40    16        INIT_FCALL                                               'var_export'
   41    17        INIT_FCALL                                               'array_reduce'
   42    18        SEND_VAR                                                 !0
   43    19        DECLARE_LAMBDA_FUNCTION                          ~16     [0]
   46    20        SEND_VAL                                                 ~16
   41    21        DO_ICALL                                         $17     
   46    22        SEND_VAR                                                 $17
   40    23        DO_ICALL                                                 
   48    24      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/d7n8V
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $result, !1 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   44     2        FETCH_DIM_R                                      ~2      !1, 'Continent'
          3        FETCH_DIM_R                                      ~4      !1, 'Country'
          4        FETCH_DIM_R                                      ~7      !1, 'City'
          5        FETCH_DIM_W                                      $3      !0, ~2
          6        FETCH_DIM_W                                      $5      $3, ~4
          7        ASSIGN_DIM                                               $5
          8        OP_DATA                                                  ~7
   45     9      > RETURN                                                   !0
   46    10*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.46 ms | 1008 KiB | 15 Q