3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr = [ ["year" => 1921, "name" => "bob"], ["year" => 1944, "name" => "steve"], ["year" => 1944, "name" => "doug"], ["year" => 1921, "name" => "jim"], ]; foreach ($arr as $item) { $result[$item['year']]['year'] = $item['year']; $result[$item['year']]['names'][] = ['name' => $item['name']]; } echo json_encode(['data' => array_values($result)], JSON_PRETTY_PRINT);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 16
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 16
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/NXhXlh
function name:  (null)
number of ops:  27
compiled vars:  !0 = $arr, !1 = $item, !2 = $result
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   10     1      > FE_RESET_R                                           $4      !0, ->16
          2    > > FE_FETCH_R                                                   $4, !1, ->16
   11     3    >   FETCH_DIM_R                                          ~5      !1, 'year'
          4        FETCH_DIM_R                                          ~8      !1, 'year'
          5        FETCH_DIM_W                                          $6      !2, ~5
          6        ASSIGN_DIM                                                   $6, 'year'
          7        OP_DATA                                                      ~8
   12     8        FETCH_DIM_R                                          ~9      !1, 'year'
          9        FETCH_DIM_R                                          ~13     !1, 'name'
         10        INIT_ARRAY                                           ~14     ~13, 'name'
         11        FETCH_DIM_W                                          $10     !2, ~9
         12        FETCH_DIM_W                                          $11     $10, 'names'
         13        ASSIGN_DIM                                                   $11
         14        OP_DATA                                                      ~14
   10    15      > JMP                                                          ->2
         16    >   FE_FREE                                                      $4
   15    17        INIT_FCALL                                                   'json_encode'
         18        INIT_FCALL                                                   'array_values'
         19        SEND_VAR                                                     !2
         20        DO_ICALL                                             $15     
         21        INIT_ARRAY                                           ~16     $15, 'data'
         22        SEND_VAL                                                     ~16
         23        SEND_VAL                                                     128
         24        DO_ICALL                                             $17     
         25        ECHO                                                         $17
         26      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
176.01 ms | 2214 KiB | 15 Q