Source Code:
(back to article)
<?php $numbers = array(1, 2, 3, 4, 5); $indicesToRemove = array(2, 4); // Remove elements at indices 2 and 4 $keepIndices = array_diff(array_keys($numbers), $indicesToRemove); $keepElements = array_intersect_key($numbers, array_flip($keepIndices)); $newArray = array_merge($keepElements); // ?>
Result:
Report an issue