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'] ]; $result = []; foreach ($array as $row) { $result[$row['Categoria']]['Servico'] = $row['Categoria']; $result[$row['Categoria']]['children'][] = $row['Servico']; } var_export(array_values($result));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 16
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 16
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/9PCqW
function name:  (null)
number of ops:  24
compiled vars:  !0 = $array, !1 = $result, !2 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   15     1        ASSIGN                                                   !1, <array>
   16     2      > FE_RESET_R                                       $5      !0, ->16
          3    > > FE_FETCH_R                                               $5, !2, ->16
   17     4    >   FETCH_DIM_R                                      ~6      !2, 'Categoria'
          5        FETCH_DIM_R                                      ~9      !2, 'Categoria'
          6        FETCH_DIM_W                                      $7      !1, ~6
          7        ASSIGN_DIM                                               $7, 'Servico'
          8        OP_DATA                                                  ~9
   18     9        FETCH_DIM_R                                      ~10     !2, 'Categoria'
         10        FETCH_DIM_R                                      ~14     !2, 'Servico'
         11        FETCH_DIM_W                                      $11     !1, ~10
         12        FETCH_DIM_W                                      $12     $11, 'children'
         13        ASSIGN_DIM                                               $12
         14        OP_DATA                                                  ~14
   16    15      > JMP                                                      ->3
         16    >   FE_FREE                                                  $5
   20    17        INIT_FCALL                                               'var_export'
         18        INIT_FCALL                                               'array_values'
         19        SEND_VAR                                                 !1
         20        DO_ICALL                                         $15     
         21        SEND_VAR                                                 $15
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.01 ms | 1003 KiB | 15 Q