3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ "elem-1" => ["title" => "1", "desc" => ""], "elem-2" => ["title" => "2", "desc" => ""], "elem-3" => ["title" => "3", "desc" => ""], "elem-4" => ["title" => "4", "desc" => ""], ]; $result = []; array_walk( $arr, function($row, $key) use(&$result) { $result[] = [$key => $row['title']]; } ); var_export($result); echo "\n---\n"; $result = []; foreach ($arr as $key => $row) { $result[] = [$key => $row['title']]; } var_export($result); echo "\n---\n"; var_export(array_chunk(array_map(fn($row) => $row['title'], $arr), 1, true));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 21
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 21
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/BREsW
function name:  (null)
number of ops:  40
compiled vars:  !0 = $arr, !1 = $result, !2 = $row, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   10     1        ASSIGN                                                   !1, <array>
   11     2        INIT_FCALL                                               'array_walk'
   12     3        SEND_REF                                                 !0
   13     4        DECLARE_LAMBDA_FUNCTION                          ~6      [0]
          5        BIND_LEXICAL                                             ~6, !1
   15     6        SEND_VAL                                                 ~6
   11     7        DO_ICALL                                                 
   17     8        INIT_FCALL                                               'var_export'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
   19    11        ECHO                                                     '%0A---%0A'
   21    12        ASSIGN                                                   !1, <array>
   22    13      > FE_RESET_R                                       $10     !0, ->21
         14    > > FE_FETCH_R                                       ~11     $10, !2, ->21
         15    >   ASSIGN                                                   !3, ~11
   23    16        FETCH_DIM_R                                      ~14     !2, 'title'
         17        INIT_ARRAY                                       ~15     ~14, !3
         18        ASSIGN_DIM                                               !1
         19        OP_DATA                                                  ~15
   22    20      > JMP                                                      ->14
         21    >   FE_FREE                                                  $10
   25    22        INIT_FCALL                                               'var_export'
         23        SEND_VAR                                                 !1
         24        DO_ICALL                                                 
   27    25        ECHO                                                     '%0A---%0A'
   29    26        INIT_FCALL                                               'var_export'
         27        INIT_FCALL                                               'array_chunk'
         28        INIT_FCALL                                               'array_map'
         29        DECLARE_LAMBDA_FUNCTION                          ~17     [1]
         30        SEND_VAL                                                 ~17
         31        SEND_VAR                                                 !0
         32        DO_ICALL                                         $18     
         33        SEND_VAR                                                 $18
         34        SEND_VAL                                                 1
         35        SEND_VAL                                                 <true>
         36        DO_ICALL                                         $19     
         37        SEND_VAR                                                 $19
         38        DO_ICALL                                                 
         39      > 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/BREsW
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $row, !1 = $key, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   14     3        FETCH_DIM_R                                      ~4      !0, 'title'
          4        INIT_ARRAY                                       ~5      ~4, !1
          5        ASSIGN_DIM                                               !2
          6        OP_DATA                                                  ~5
   15     7      > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BREsW
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
          1        FETCH_DIM_R                                      ~1      !0, 'title'
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.28 ms | 1008 KiB | 17 Q