How to Reset PHP Array Index


May 05, 2014    Janaki Mahapatra, Internet

To reset array index we can use the function array_values(). Example:
$a = array(
    3 => "Apple",
    7 => "Mango",
    45 => "Orange"
);
$b = array_values($a);
print_r($b);
Array
(
    [0] => Apple
    [1] => Mango
    [2] => Orange
)