3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [ 'name' => 'Umber', 'reason' => 'No data', 'id' => '12' ], [ 'name' => 'Jakar', 'reason' => 'Wrong format', 'id' => '12' ], [ 'name' => 'Lane', 'reason' => 'No data', 'id' => '12' ], [ 'name' => 'Jake', 'reason' => 'Not found', 'id' => '13' ], [ 'name' => 'Jame', 'reason' => 'Wrong name', 'id' => '13' ], [ 'name' => 'Joe', 'reason' => 'No data', 'id' => '13' ] ]; $result = []; foreach ($array as $row) { $result[$row['id']][] = $row['reason']; } var_export($result); echo "\n---\n"; var_export( array_reduce( $array, function($result, $row) { $result[$row['id']][] = $row['reason']; return $result; }, [] ) );
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 10
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/gNoTK
function name:  (null)
number of ops:  25
compiled vars:  !0 = $array, !1 = $result, !2 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   36     1        ASSIGN                                                   !1, <array>
   37     2      > FE_RESET_R                                       $5      !0, ->10
          3    > > FE_FETCH_R                                               $5, !2, ->10
   38     4    >   FETCH_DIM_R                                      ~6      !2, 'id'
          5        FETCH_DIM_R                                      ~9      !2, 'reason'
          6        FETCH_DIM_W                                      $7      !1, ~6
          7        ASSIGN_DIM                                               $7
          8        OP_DATA                                                  ~9
   37     9      > JMP                                                      ->3
         10    >   FE_FREE                                                  $5
   40    11        INIT_FCALL                                               'var_export'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                                 
   42    14        ECHO                                                     '%0A---%0A'
   44    15        INIT_FCALL                                               'var_export'
   45    16        INIT_FCALL                                               'array_reduce'
   46    17        SEND_VAR                                                 !0
   47    18        DECLARE_LAMBDA_FUNCTION                          ~11     [0]
   50    19        SEND_VAL                                                 ~11
   51    20        SEND_VAL                                                 <array>
   45    21        DO_ICALL                                         $12     
   51    22        SEND_VAR                                                 $12
   44    23        DO_ICALL                                                 
   53    24      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gNoTK
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $result, !1 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   48     2        FETCH_DIM_R                                      ~2      !1, 'id'
          3        FETCH_DIM_R                                      ~5      !1, 'reason'
          4        FETCH_DIM_W                                      $3      !0, ~2
          5        ASSIGN_DIM                                               $3
          6        OP_DATA                                                  ~5
   49     7      > RETURN                                                   !0
   50     8*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.42 ms | 1002 KiB | 15 Q