3v4l.org

run code in 300+ PHP versions simultaneously
<?php $records = [ ['id' => 2135, 'first_name' => 'John', 'last_name' => 'Cena'], ['id' => 5623, 'first_name' => 'Peter', 'last_name' => 'Doe'], ]; $result = []; foreach ($records as $row) { $result[array_shift($row)] = implode(' ', $row); } var_export($result); echo "\n---\n"; var_export( array_reduce( $records, fn($result, $row) => $result + [array_shift($row) => implode(' ', $row)], [] ) );
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 14
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 14
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/aCIee
function name:  (null)
number of ops:  29
compiled vars:  !0 = $records, !1 = $result, !2 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    8     1        ASSIGN                                                   !1, <array>
    9     2      > FE_RESET_R                                       $5      !0, ->14
          3    > > FE_FETCH_R                                               $5, !2, ->14
   10     4    >   INIT_FCALL                                               'array_shift'
          5        SEND_REF                                                 !2
          6        DO_ICALL                                         $6      
          7        INIT_FCALL                                               'implode'
          8        SEND_VAL                                                 '+'
          9        SEND_VAR                                                 !2
         10        DO_ICALL                                         $8      
         11        ASSIGN_DIM                                               !1, $6
         12        OP_DATA                                                  $8
    9    13      > JMP                                                      ->3
         14    >   FE_FREE                                                  $5
   12    15        INIT_FCALL                                               'var_export'
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                                 
   14    18        ECHO                                                     '%0A---%0A'
   15    19        INIT_FCALL                                               'var_export'
   16    20        INIT_FCALL                                               'array_reduce'
   17    21        SEND_VAR                                                 !0
   18    22        DECLARE_LAMBDA_FUNCTION                          ~10     [0]
         23        SEND_VAL                                                 ~10
   19    24        SEND_VAL                                                 <array>
   16    25        DO_ICALL                                         $11     
   19    26        SEND_VAR                                                 $11
   15    27        DO_ICALL                                                 
   21    28      > 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/aCIee
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $result, !1 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        INIT_FCALL                                               'array_shift'
          3        SEND_REF                                                 !1
          4        DO_ICALL                                         $2      
          5        INIT_FCALL                                               'implode'
          6        SEND_VAL                                                 '+'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $3      
          9        INIT_ARRAY                                       ~4      $3, $2
         10        ADD                                              ~5      !0, ~4
         11      > RETURN                                                   ~5
         12*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.57 ms | 1013 KiB | 17 Q