3v4l.org

run code in 300+ PHP versions simultaneously
<?php $modules = [ [ "id_modulo" => "114", "nome_modulo" => "1. Acessos" ], [ "id_modulo" => "118", "nome_modulo" => "4. Área de Vivência" ], [ "id_modulo" => "128", "nome_modulo" => "14. Supressão" ] ]; $items = [ [ "id_modulo" => "114", "id_pergunta" => "547", "pergunta" => "Example", "resposta" => "C" ], [ "id_modulo" => "114", "id_pergunta" => "548", "pergunta" => "Example", "resposta" => "C" ], [ "id_modulo" => "118", "id_pergunta" => "549", "pergunta" => "Example", "resposta" => "C" ], [ "id_modulo" => "114", "id_pergunta" => "550", "pergunta" => "Example", "resposta" => "C" ], ]; $result = []; foreach (array_merge($modules, $items) as $row) { if (isset($row['nome_modulo'])) { $result[$row['id_modulo']] = $row + ['items' => []]; } else { $result[$row['id_modulo']]['items'][] = $row; } } var_export(array_values($result));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 22
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 22
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 16
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/LibIO
function name:  (null)
number of ops:  30
compiled vars:  !0 = $modules, !1 = $items, !2 = $result, !3 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   19     1        ASSIGN                                                   !1, <array>
   46     2        ASSIGN                                                   !2, <array>
   47     3        INIT_FCALL                                               'array_merge'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $7      
          7      > FE_RESET_R                                       $8      $7, ->22
          8    > > FE_FETCH_R                                               $8, !3, ->22
   48     9    >   ISSET_ISEMPTY_DIM_OBJ                         0          !3, 'nome_modulo'
         10      > JMPZ                                                     ~9, ->16
   49    11    >   FETCH_DIM_R                                      ~10     !3, 'id_modulo'
         12        ADD                                              ~12     !3, <array>
         13        ASSIGN_DIM                                               !2, ~10
         14        OP_DATA                                                  ~12
   48    15      > JMP                                                      ->21
   51    16    >   FETCH_DIM_R                                      ~13     !3, 'id_modulo'
         17        FETCH_DIM_W                                      $14     !2, ~13
         18        FETCH_DIM_W                                      $15     $14, 'items'
         19        ASSIGN_DIM                                               $15
         20        OP_DATA                                                  !3
   47    21    > > JMP                                                      ->8
         22    >   FE_FREE                                                  $8
   54    23        INIT_FCALL                                               'var_export'
         24        INIT_FCALL                                               'array_values'
         25        SEND_VAR                                                 !2
         26        DO_ICALL                                         $17     
         27        SEND_VAR                                                 $17
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
193.96 ms | 1001 KiB | 16 Q