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);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 0 => 'Title', 1 => 'image_url', 3 => 'SKU CODE', 4 => 'TITLE SIZE', 5 => 'DESCRIPTION', 6 => 'BASE SKU', ), 1 => array ( 0 => 'A witch and her cat live here', 1 => 'https://beautifulhomegifts.com/a-witch-and-her-cat-live-here/', 2 => 'BHG-MS-AWAHCLH030720', 3 => 'A witch and her cat live here', 4 => 'A witch and her cat live here', ), 2 => array ( 0 => '', 1 => '', 2 => 'BHG-MS-AWAHCLH030720-A5', 3 => 'A witch and her cat live here - 150mm x 200mm', 4 => 'A witch and her cat live here', 5 => 'BHG-MS-AWAHCLH030720', ), 3 => array ( 0 => '', 1 => '', 2 => 'BHG-MS-AWAHCLH030720-A4', 3 => 'A witch and her cat live here - 201mm x 305mm', 4 => 'A witch and her cat live here', 5 => 'BHG-MS-AWAHCLH030720', ), 4 => array ( 0 => '', 1 => '', 2 => 'BHG-MS-AWAHCLH030720-A3', 3 => 'A witch and her cat live here - 305mm x 400mm', 4 => 'A witch and her cat live here', 5 => 'BHG-MS-AWAHCLH030720', ), 5 => array ( 0 => 'Autism House Rules', 1 => 'https://beautifulhomegifts.com/autism-house-rules/', 2 => 'BHG-MS-AHR030720', 3 => 'Autism House Rules', 4 => 'Autism House Rules', ), 6 => array ( 0 => '', 1 => '', 2 => 'BHG-MS-AHR030720-A5', 3 => 'Autism House Rules - 150mm x 200mm', 4 => 'Autism House Rules', 5 => 'BHG-MS-AHR030720', ), 7 => array ( 0 => '', 1 => '', 2 => 'BHG-MS-AHR030720-A4', 3 => 'Autism House Rules - 201mm x 305mm', 4 => 'Autism House Rules', 5 => 'BHG-MS-AHR030720', ), 8 => array ( 0 => '', 1 => '', 2 => 'BHG-MS-AHR030720-A3', 3 => 'Autism House Rules - 305mm x 400mm', 4 => 'Autism House Rules', 5 => 'BHG-MS-AHR030720', ), )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
61.19 ms | 411 KiB | 5 Q