3v4l.org

run code in 300+ PHP versions simultaneously
<?php $month = [ 'January', 'January', 'January', 'January', 'February' ]; $weeks = [ 'Week 1', 'Week 2', 'Week 3', 'Week 4', 'Week 1' ]; $newArray = []; foreach ($month as $index => $value) { // Create the new string you want, using the same index for both arrays $newArray[] = $value . ' - ' . $weeks[$index]; } print_r($newArray);
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Array ( [0] => January - Week 1 [1] => January - Week 2 [2] => January - Week 3 [3] => January - Week 4 [4] => February - Week 1 )

preferences:
89.14 ms | 403 KiB | 123 Q