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

Deleting array elements in JavaScript – delete vs splice

delete will delete the object property, but will not reindex the array or update its length. This makes it appears as if it is undefined: > myArray = [‘a’, ‘b’, ‘c’, ‘d’] [“a”, “b”, “c”, “d”] > delete myArray[0] true > myArray[0] undefined Note that it is not in fact set to the value undefined, … Read more