3v4l.org

run code in 300+ 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 getGroupedArray($array, $keyFieldsToGroup) { $newArray = array(); foreach ($array as $record) $newArray = getRecursiveArray($record, $keyFieldsToGroup, $newArray); return $newArray; } function getRecursiveArray($itemArray, $keys, $newArray) { if (count($keys) > 1) $newArray[$itemArray[$keys[0]]] = getRecursiveArray($itemArray, array_splice($keys, 1), $newArray[$itemArray[$keys[0]]]); else $newArray[$itemArray[$keys[0]]][] = $itemArray; return $newArray; } var_export( getGroupedArray($array, ['id', 'shipping_no']) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1fuF3
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>
   44     1        INIT_FCALL                                               'var_export'
   45     2        INIT_FCALL                                               'getgroupedarray'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 <array>
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
   44     7        DO_ICALL                                                 
   46     8      > RETURN                                                   1

Function getgroupedarray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/1fuF3
function name:  getGroupedArray
number of ops:  15
compiled vars:  !0 = $array, !1 = $keyFieldsToGroup, !2 = $newArray, !3 = $record
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   28     2        ASSIGN                                                   !2, <array>
   30     3      > FE_RESET_R                                       $5      !0, ->12
          4    > > FE_FETCH_R                                               $5, !3, ->12
   31     5    >   INIT_FCALL_BY_NAME                                       'getRecursiveArray'
          6        SEND_VAR_EX                                              !3
          7        SEND_VAR_EX                                              !1
          8        SEND_VAR_EX                                              !2
          9        DO_FCALL                                      0  $6      
         10        ASSIGN                                                   !2, $6
   30    11      > JMP                                                      ->4
         12    >   FE_FREE                                                  $5
   33    13      > RETURN                                                   !2
   34    14*     > RETURN                                                   null

End of function getgroupedarray

Function getrecursivearray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 24
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1fuF3
function name:  getRecursiveArray
number of ops:  31
compiled vars:  !0 = $itemArray, !1 = $keys, !2 = $newArray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   36     3        COUNT                                            ~3      !1
          4        IS_SMALLER                                               1, ~3
          5      > JMPZ                                                     ~4, ->24
   37     6    >   FETCH_DIM_R                                      ~5      !1, 0
          7        FETCH_DIM_R                                      ~6      !0, ~5
          8        INIT_FCALL_BY_NAME                                       'getRecursiveArray'
          9        SEND_VAR_EX                                              !0
         10        INIT_FCALL                                               'array_splice'
         11        SEND_REF                                                 !1
         12        SEND_VAL                                                 1
         13        DO_ICALL                                         $8      
         14        SEND_VAR_NO_REF_EX                                       $8
         15        CHECK_FUNC_ARG                                           
         16        FETCH_DIM_R                                      ~9      !1, 0
         17        FETCH_DIM_R                                      ~10     !0, ~9
         18        FETCH_DIM_FUNC_ARG                               $11     !2, ~10
         19        SEND_FUNC_ARG                                            $11
         20        DO_FCALL                                      0  $12     
         21        ASSIGN_DIM                                               !2, ~6
         22        OP_DATA                                                  $12
   36    23      > JMP                                                      ->29
   39    24    >   FETCH_DIM_R                                      ~13     !1, 0
         25        FETCH_DIM_R                                      ~14     !0, ~13
         26        FETCH_DIM_W                                      $15     !2, ~14
         27        ASSIGN_DIM                                               $15
         28        OP_DATA                                                  !0
   41    29    > > RETURN                                                   !2
   42    30*     > RETURN                                                   null

End of function getrecursivearray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.76 ms | 1018 KiB | 16 Q