Insert elements from one array (one-at-a-time) after every second element of another array (un-even zippering)
This example will work regardless of the $a and $b array size. <?php $a = [‘A1’, ‘A2’, ‘A3’, ‘A4’, ‘A5’]; $b = [‘BB1’, ‘BB2’, ‘BB3’, ‘BB4’, ‘BB5’]; for ($i = 0; $i < count($b); $i++) { array_splice($a, ($i+1)*2+$i, 0, $b[$i]); } echo “<pre>” . print_r($a, true) . “</pre>”; Output of this example is : Array … Read more