I have an array:
Array
(
[0] => ololo
[2] => test
[3] => haha
[7] => nice
)
How can I change the indexes of the array to this:
Array
(
[0] => ololo
[1] => test
[2] => haha
[3] => nice
)
From PHP.net:
array_values() returns all the values from the input array and indexes the array numerically.
$arr = array_values($arr);
array_values() is probably what you want. See: http://php.net/function.array-values
$myArray = array_values($myArray);
If you have your initial array within $a
variable, you can just do the following:
$a = array_values($a);
Which will basically return values from within your original array, and will do it in the another array.
Is it clear enough?