array(
[0]=>1
[1]=>2
[2]=>3
[3]=>4
)
If delete second element, you have
array(
[0]=>1
[2]=>3
[3]=>4
)
Now how to change indexes to
array(
[0]=>1
[1]=>3
[2]=>4
)
array(
[0]=>1
[1]=>2
[2]=>3
[3]=>4
)
If delete second element, you have
array(
[0]=>1
[2]=>3
[3]=>4
)
Now how to change indexes to
array(
[0]=>1
[1]=>3
[2]=>4
)
If you want to re-index your array starting to zero, simply do the following:
$myNewArray = array_values($myOldArry);
From the php docs: http://php.net/manual/en/function.array-splice.php
array_splice: Removes the elements designated by offset and length from the input array, and replaces them with the elements of the replacement array, if supplied.
So, you would use:
$arr = array(1,2,3,4);
array_splice($arr, 2, 1); //Will give you an array: [1, 2, 4]