3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = Array ( Array ( "id" => 99, "fruit" => "Apple", "color" => "Green" ), Array ( "id" => 99, "fruit" => "Apple", "color" => "Red" ), Array ( "id" => 555, "fruit" => "Banana", "color" => "Yellow" ) ); $ids = array_column($arr, "id"); Foreach(array_unique($ids) as $id){ $new[$id] = array_values(array_intersect_key($arr, array_intersect($ids, [$id]))); } Var_dump($new);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 26
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 26
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/YJWuV
function name:  (null)
number of ops:  31
compiled vars:  !0 = $arr, !1 = $ids, !2 = $id, !3 = $new
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   25     1        INIT_FCALL                                               'array_column'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'id'
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !1, $5
   27     6        INIT_FCALL                                               'array_unique'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $7      
          9      > FE_RESET_R                                       $8      $7, ->26
         10    > > FE_FETCH_R                                               $8, !2, ->26
   28    11    >   INIT_FCALL                                               'array_values'
         12        INIT_FCALL                                               'array_intersect_key'
         13        SEND_VAR                                                 !0
         14        INIT_FCALL                                               'array_intersect'
         15        SEND_VAR                                                 !1
         16        INIT_ARRAY                                       ~10     !2
         17        SEND_VAL                                                 ~10
         18        DO_ICALL                                         $11     
         19        SEND_VAR                                                 $11
         20        DO_ICALL                                         $12     
         21        SEND_VAR                                                 $12
         22        DO_ICALL                                         $13     
         23        ASSIGN_DIM                                               !3, !2
         24        OP_DATA                                                  $13
   27    25      > JMP                                                      ->10
         26    >   FE_FREE                                                  $8
   30    27        INIT_FCALL                                               'var_dump'
         28        SEND_VAR                                                 !3
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
265.56 ms | 1017 KiB | 19 Q