3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [ 0 => 'Title', 1 => 'image_url', 3 => 'SKU CODE', 4 => 'TITLE SIZE', 5 => 'DESCRIPTION', 6 => 'BASE SKU', ], [ 0 => 'A witch and her cat live here', 1 => 'https://beautifulhomegifts.com/a-witch-and-her-cat-live-here/', 3 => [ 0 => 'BHG-MS-AWAHCLH030720', 1 => 'BHG-MS-AWAHCLH030720-A5', 2 => 'BHG-MS-AWAHCLH030720-A4', 3 => 'BHG-MS-AWAHCLH030720-A3', ], 4 => [ 0 => 'A witch and her cat live here', 1 => 'A witch and her cat live here - 150mm x 200mm', 2 => 'A witch and her cat live here - 201mm x 305mm', 3 => 'A witch and her cat live here - 305mm x 400mm', ], 5 => [ 0 => 'A witch and her cat live here', 1 => 'A witch and her cat live here', 2 => 'A witch and her cat live here', 3 => 'A witch and her cat live here', ], 6 => [ 1 => 'BHG-MS-AWAHCLH030720', 2 => 'BHG-MS-AWAHCLH030720', 3 => 'BHG-MS-AWAHCLH030720', ], ], 2 => [ 0 => '', 1 => '', ], 3 => [ 0 => '', 1 => '', ], 4 => [ 0 => '', 1 => '', ], 5 => [ 0 => 'Autism House Rules', 1 => 'https://beautifulhomegifts.com/autism-house-rules/', 3 => [ 0 => 'BHG-MS-AHR030720', 1 => 'BHG-MS-AHR030720-A5', 2 => 'BHG-MS-AHR030720-A4', 3 => 'BHG-MS-AHR030720-A3', ], 4 => [ 0 => 'Autism House Rules', 1 => 'Autism House Rules - 150mm x 200mm', 2 => 'Autism House Rules - 201mm x 305mm', 3 => 'Autism House Rules - 305mm x 400mm', ], 5 => [ 0 => 'Autism House Rules', 1 => 'Autism House Rules', 2 => 'Autism House Rules', 3 => 'Autism House Rules', ], 6 => [ 1 => 'BHG-MS-AHR030720', 2 => 'BHG-MS-AHR030720', 3 => 'BHG-MS-AHR030720', ], ] ]; $headers = array_shift($array); // $fhandle = fopen("new.csv", "a"); // fputcsv($fhandle, $headers); $demo[] = $headers; foreach ($array as $row) { if (empty($row[0])) { continue; } $group = array_splice($row, 0, 2); foreach ($row[0] as $column => $notUsed) { /* fputcsv($fhandle, array_merge( !$column ? $group : ['', ''], array_column($row, $column) )); */ $demo[] = array_merge( !$column ? $group : ['', ''], array_column($row, $column) ); } } // fclose($fhandle); var_export($demo);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 40
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 40
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 12
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 12
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 38
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 38
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 27
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 38
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
filename:       /in/jpu81
function name:  (null)
number of ops:  45
compiled vars:  !0 = $array, !1 = $headers, !2 = $demo, !3 = $row, !4 = $group, !5 = $notUsed, !6 = $column
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   80     1        INIT_FCALL                                               'array_shift'
          2        SEND_REF                                                 !0
          3        DO_ICALL                                         $8      
          4        ASSIGN                                                   !1, $8
   85     5        ASSIGN_DIM                                               !2
          6        OP_DATA                                                  !1
   87     7      > FE_RESET_R                                       $11     !0, ->40
          8    > > FE_FETCH_R                                               $11, !3, ->40
   88     9    >   ISSET_ISEMPTY_DIM_OBJ                         1          !3, 0
         10      > JMPZ                                                     ~12, ->12
   89    11    > > JMP                                                      ->8
   91    12    >   INIT_FCALL                                               'array_splice'
         13        SEND_REF                                                 !3
         14        SEND_VAL                                                 0
         15        SEND_VAL                                                 2
         16        DO_ICALL                                         $13     
         17        ASSIGN                                                   !4, $13
   93    18        FETCH_DIM_R                                      ~15     !3, 0
         19      > FE_RESET_R                                       $16     ~15, ->38
         20    > > FE_FETCH_R                                       ~17     $16, !5, ->38
         21    >   ASSIGN                                                   !6, ~17
   98    22        INIT_FCALL                                               'array_merge'
   99    23        BOOL_NOT                                         ~20     !6
         24      > JMPZ                                                     ~20, ->27
         25    >   QM_ASSIGN                                        ~21     !4
         26      > JMP                                                      ->28
         27    >   QM_ASSIGN                                        ~21     <array>
         28    >   SEND_VAL                                                 ~21
  100    29        INIT_FCALL                                               'array_column'
         30        SEND_VAR                                                 !3
         31        SEND_VAR                                                 !6
         32        DO_ICALL                                         $22     
         33        SEND_VAR                                                 $22
   98    34        DO_ICALL                                         $23     
         35        ASSIGN_DIM                                               !2
  100    36        OP_DATA                                                  $23
   93    37      > JMP                                                      ->20
         38    >   FE_FREE                                                  $16
   87    39      > JMP                                                      ->8
         40    >   FE_FREE                                                  $11
  106    41        INIT_FCALL                                               'var_export'
         42        SEND_VAR                                                 !2
         43        DO_ICALL                                                 
         44      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.72 ms | 1442 KiB | 18 Q