3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['Categoria' => 'example', 'Servico' => 'name1'], ['Categoria' => 'example', 'Servico' => 'name2'], ['Categoria' => 'example', 'Servico' => 'name3'], ['Categoria' => 'example2', 'Servico' => 'name4'], ['Categoria' => 'example2', 'Servico' => 'name5'], ['Categoria' => 'example2', 'Servico' => 'name6'], ['Categoria' => 'example3', 'Servico' => 'name7'], ['Categoria' => 'example3', 'Servico' => 'name8'], ['Categoria' => 'example3', 'Servico' => 'name9'] ]; var_export( array_values( array_reduce( $array, function ($carry, $row) { $carry[$row['Categoria']]['Servico'] = $row['Categoria']; $carry[$row['Categoria']]['children'][] = $row['Servico']; return $carry; } ) ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/csppI
function name:  (null)
number of ops:  13
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   15     1        INIT_FCALL                                               'var_export'
   16     2        INIT_FCALL                                               'array_values'
   17     3        INIT_FCALL                                               'array_reduce'
   18     4        SEND_VAR                                                 !0
   19     5        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
   23     6        SEND_VAL                                                 ~2
   17     7        DO_ICALL                                         $3      
   23     8        SEND_VAR                                                 $3
   16     9        DO_ICALL                                         $4      
   23    10        SEND_VAR                                                 $4
   15    11        DO_ICALL                                                 
   26    12      > 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/csppI
function name:  {closure}
number of ops:  15
compiled vars:  !0 = $carry, !1 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   20     2        FETCH_DIM_R                                      ~2      !1, 'Categoria'
          3        FETCH_DIM_R                                      ~5      !1, 'Categoria'
          4        FETCH_DIM_W                                      $3      !0, ~2
          5        ASSIGN_DIM                                               $3, 'Servico'
          6        OP_DATA                                                  ~5
   21     7        FETCH_DIM_R                                      ~6      !1, 'Categoria'
          8        FETCH_DIM_R                                      ~10     !1, 'Servico'
          9        FETCH_DIM_W                                      $7      !0, ~6
         10        FETCH_DIM_W                                      $8      $7, 'children'
         11        ASSIGN_DIM                                               $8
         12        OP_DATA                                                  ~10
   22    13      > RETURN                                                   !0
   23    14*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.13 ms | 1001 KiB | 16 Q