3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ (object) [ 'C1' => 'C1V1', 'C2' => 'C2V1', 'C3' => 'C3V1', ], (object) [ 'C1' => 'C1V2', 'C2' => 'C2V2', 'C3' => 'C3V2', ] ]; $arr = json_decode(json_encode($arr), true); // format //[["C1","C2","C3],[C1V1,C2V1,C3V1],[C1V2,C2V2,C3V3]] $i=0; $newArr[0] = array_keys($arr[0]); foreach($arr as $record) { $i++; foreach($record as $col => $val) { $newArr[$i][] = $val; } } print_r($newArr);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 32
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 32
Branch analysis from position: 22
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 30
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 30
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 30
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/2ZYM9
function name:  (null)
number of ops:  37
compiled vars:  !0 = $arr, !1 = $i, !2 = $newArr, !3 = $record, !4 = $val, !5 = $col
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   CAST                                          8  ~6      <array>
          1        INIT_ARRAY                                       ~7      ~6
    9     2        CAST                                          8  ~8      <array>
          3        ADD_ARRAY_ELEMENT                                ~7      ~8
    2     4        ASSIGN                                                   !0, ~7
   14     5        INIT_FCALL                                               'json_decode'
          6        INIT_FCALL                                               'json_encode'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $10     
          9        SEND_VAR                                                 $10
         10        SEND_VAL                                                 <true>
         11        DO_ICALL                                         $11     
         12        ASSIGN                                                   !0, $11
   19    13        ASSIGN                                                   !1, 0
   20    14        INIT_FCALL                                               'array_keys'
         15        FETCH_DIM_R                                      ~15     !0, 0
         16        SEND_VAL                                                 ~15
         17        DO_ICALL                                         $16     
         18        ASSIGN_DIM                                               !2, 0
         19        OP_DATA                                                  $16
   21    20      > FE_RESET_R                                       $17     !0, ->32
         21    > > FE_FETCH_R                                               $17, !3, ->32
   22    22    >   PRE_INC                                                  !1
   23    23      > FE_RESET_R                                       $19     !3, ->30
         24    > > FE_FETCH_R                                       ~20     $19, !4, ->30
         25    >   ASSIGN                                                   !5, ~20
   24    26        FETCH_DIM_W                                      $22     !2, !1
         27        ASSIGN_DIM                                               $22
         28        OP_DATA                                                  !4
   23    29      > JMP                                                      ->24
         30    >   FE_FREE                                                  $19
   21    31      > JMP                                                      ->21
         32    >   FE_FREE                                                  $17
   28    33        INIT_FCALL                                               'print_r'
         34        SEND_VAR                                                 !2
         35        DO_ICALL                                                 
         36      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.39 ms | 1018 KiB | 17 Q