3v4l.org

run code in 300+ PHP versions simultaneously
<?php $locations = array('loc1','loc2','loc3','loc4'); $input1 = array('A1','A2','A3','A4','A5'); $input2 = array('B1','B2','B3','B4','B5'); $input3 = array('C1','C2','C3','C4','C5'); $OutToCVS = []; foreach ($locations as $loc) { $OutToCVS[] = array_merge([$loc], $input1); $OutToCVS[] = array_merge([$loc], $input2); $OutToCVS[] = array_merge([$loc], $input3); } print_r($OutToCVS);

preferences:
24.63 ms | 405 KiB | 5 Q