3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [[ "continent" => "Europa", "country" => "France", "capital" => "Paris", ],[ "continent" => "Europa", "country" => "Spain", "capital" => "Madrid", ],[ "continent" => "Asia", "country" => "Russia", "capital" => "Moscow", ]]; $groupByProperty = function(array $list, string $property) { return array_reduce($list, function($grouped, $item) use(&$property) { $grouped[$item[$property]][] = $item; return $grouped; }, []); }; $groupedByContinent = $groupByProperty($data, 'continent'); var_dump($groupedByContinent);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Be3HL
function name:  (null)
number of ops:  12
compiled vars:  !0 = $data, !1 = $groupByProperty, !2 = $groupedByContinent
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   17     1        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
          2        ASSIGN                                                   !1, ~4
   24     3        INIT_DYNAMIC_CALL                                        !1
          4        SEND_VAR_EX                                              !0
          5        SEND_VAL_EX                                              'continent'
          6        DO_FCALL                                      0  $6      
          7        ASSIGN                                                   !2, $6
   26     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !2
         10        DO_ICALL                                                 
         11      > 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/Be3HL
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $list, !1 = $property
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   18     2        INIT_FCALL                                               'array_reduce'
          3        SEND_VAR                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
          5        BIND_LEXICAL                                             ~2, !1
   21     6        SEND_VAL                                                 ~2
          7        SEND_VAL                                                 <array>
   18     8        DO_ICALL                                         $3      
   21     9      > RETURN                                                   $3
   22    10*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Be3HL
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $grouped, !1 = $item, !2 = $property
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   19     3        FETCH_DIM_R                                      ~3      !1, !2
          4        FETCH_DIM_W                                      $4      !0, ~3
          5        ASSIGN_DIM                                               $4
          6        OP_DATA                                                  !1
   20     7      > RETURN                                                   !0
   21     8*     > RETURN                                                   null

End of Dynamic Function 0

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
184.24 ms | 1461 KiB | 15 Q