3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ [ "id" => 96, "shipping_no" => "212755-1", "part_no" => "reterty", "description" => "tyrfyt", "packaging_type" => "PC" ], [ "id" => 96, "shipping_no" => "212755-1", "part_no" => "dftgtryh", "description" => "dfhgfyh", "packaging_type" => "PC" ], [ "id" => 97, "shipping_no" => "212755-2", "part_no" => "ZeoDark", "description" => "s%c%s%c%s", "packaging_type" => "PC" ] ]; function array_group_by_keys(&$arr, $keys) { if (count($arr) < 2){ $arr = array_shift($arr[0]); return; } foreach ($arr as $k => $item) { $fvalue = array_shift($item); $arr[$fvalue][] = $item; unset($arr[$k]); } array_shift($keys); foreach ($arr as &$sub_arr) { array_group_by_keys($sub_arr, $keys); } } array_group_by_keys($array, ['id', 'shipping_no']); var_export($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SvD7s
function name:  (null)
number of ops:  9
compiled vars:  !0 = $array
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   46     1        INIT_FCALL                                                   'array_group_by_keys'
          2        SEND_REF                                                     !0
          3        SEND_VAL                                                     <array>
          4        DO_FCALL                                          0          
   47     5        INIT_FCALL                                                   'var_export'
          6        SEND_VAR                                                     !0
          7        DO_ICALL                                                     
          8      > RETURN                                                       1

Function array_group_by_keys:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 23
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 23
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 23
2 jumps found. (Code = 125) Position 1 = 28, Position 2 = 34
Branch analysis from position: 28
2 jumps found. (Code = 126) Position 1 = 29, Position 2 = 34
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
Branch analysis from position: 23
filename:       /in/SvD7s
function name:  array_group_by_keys
number of ops:  36
compiled vars:  !0 = $arr, !1 = $keys, !2 = $item, !3 = $k, !4 = $fvalue, !5 = $sub_arr
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   27     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   29     2        COUNT                                                ~6      !0
          3        IS_SMALLER                                                   ~6, 2
          4      > JMPZ                                                         ~7, ->11
   30     5    >   INIT_FCALL                                                   'array_shift'
          6        FETCH_DIM_W                                          $8      !0, 0
          7        SEND_REF                                                     $8
          8        DO_ICALL                                             $9      
          9        ASSIGN                                                       !0, $9
   31    10      > RETURN                                                       null
   34    11    > > FE_RESET_R                                           $11     !0, ->23
         12    > > FE_FETCH_R                                           ~12     $11, !2, ->23
         13    >   ASSIGN                                                       !3, ~12
   35    14        INIT_FCALL                                                   'array_shift'
         15        SEND_REF                                                     !2
         16        DO_ICALL                                             $14     
         17        ASSIGN                                                       !4, $14
   36    18        FETCH_DIM_W                                          $16     !0, !4
         19        ASSIGN_DIM                                                   $16
         20        OP_DATA                                                      !2
   37    21        UNSET_DIM                                                    !0, !3
   34    22      > JMP                                                          ->12
         23    >   FE_FREE                                                      $11
   40    24        INIT_FCALL                                                   'array_shift'
         25        SEND_REF                                                     !1
         26        DO_ICALL                                                     
   41    27      > FE_RESET_RW                                          $19     !0, ->34
         28    > > FE_FETCH_RW                                                  $19, !5, ->34
   42    29    >   INIT_FCALL_BY_NAME                                           'array_group_by_keys'
         30        SEND_VAR_EX                                                  !5
         31        SEND_VAR_EX                                                  !1
         32        DO_FCALL                                          0          
   41    33      > JMP                                                          ->28
         34    >   FE_FREE                                                      $19
   44    35      > RETURN                                                       null

End of function array_group_by_keys

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
164.02 ms | 1642 KiB | 16 Q