How to re-index all subarray elements of a multidimensional array?
To reset the keys of all arrays in an array:
$arr = array_map('array_values', $arr);
In case you just want to reset first-level array keys, use array_values()
without array_map
.
$array[9] = 'Apple';
$array[12] = 'Orange';
$array[5] = 'Peach';
$array = array_values($array);
through this function you can reset your array
$array[0] = 'Apple';
$array[1] = 'Orange';
$array[2] = 'Peach';