3v4l.org

run code in 500+ PHP versions simultaneously
<?php $a = Array ( '0' => Array ( 'location_id' => 1, 'property_id' => 10 ), '1' => Array ( 'location_id' => 2, 'property_id' => 20 ), '2' => Array ( 'location_id' => 3, 'property_id' => 10 ), '3' => Array ( 'location_id' => 4, 'property_id' => 10 ), '4' => Array ( 'location_id' => 5, 'property_id' => 10 ), '5' => Array ( 'location_id' => 6, 'property_id' => 20 ) ); $r = []; foreach($a as $v){ if(isset($r[$v['property_id']])){ array_push($r[$v['property_id']]['location_id'], $v['location_id']); }else{ $r[$v['property_id']] = [ 'property_id' => $v['property_id'], 'location_id' => [$v['location_id']] ]; } } print_r(array_values($r));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 25
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 25
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/qEFRV
function name:  (null)
number of ops:  33
compiled vars:  !0 = $a, !1 = $r, !2 = $v
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   41     1        ASSIGN                                                       !1, <array>
   42     2      > FE_RESET_R                                           $5      !0, ->25
          3    > > FE_FETCH_R                                                   $5, !2, ->25
   43     4    >   FETCH_DIM_R                                          ~6      !2, 'property_id'
          5        ISSET_ISEMPTY_DIM_OBJ                             0          !1, ~6
          6      > JMPZ                                                         ~7, ->16
   44     7    >   INIT_FCALL                                                   'array_push'
          8        FETCH_DIM_R                                          ~8      !2, 'property_id'
          9        FETCH_DIM_W                                          $9      !1, ~8
         10        FETCH_DIM_W                                          $10     $9, 'location_id'
         11        SEND_REF                                                     $10
         12        FETCH_DIM_R                                          ~11     !2, 'location_id'
         13        SEND_VAL                                                     ~11
         14        DO_ICALL                                                     
   43    15      > JMP                                                          ->24
   46    16    >   FETCH_DIM_R                                          ~13     !2, 'property_id'
   47    17        FETCH_DIM_R                                          ~15     !2, 'property_id'
         18        INIT_ARRAY                                           ~16     ~15, 'property_id'
   48    19        FETCH_DIM_R                                          ~17     !2, 'location_id'
         20        INIT_ARRAY                                           ~18     ~17
         21        ADD_ARRAY_ELEMENT                                    ~16     ~18, 'location_id'
   46    22        ASSIGN_DIM                                                   !1, ~13
   48    23        OP_DATA                                                      ~16
   42    24    > > JMP                                                          ->3
         25    >   FE_FREE                                                      $5
   52    26        INIT_FCALL                                                   'print_r'
         27        INIT_FCALL                                                   'array_values'
         28        SEND_VAR                                                     !1
         29        DO_ICALL                                             $19     
         30        SEND_VAR                                                     $19
         31        DO_ICALL                                                     
         32      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
167.61 ms | 2180 KiB | 16 Q