重命名数组键

I need to change this array's keys to 0-5, why isn't this working?

$arr = array();

while(count($arr) < 6){
    $arr[] = rand(1,53);
    $arr = array_unique($arr);
}
asort($arr);

$i = 0;
foreach($arr as $key => $value){
    //echo $i;
    $key = $i;
    $i++;
}

print '<pre>';
print_r($arr);

Thank you

Because foreach creates a copy of the array entry key and value in $key and $value. When you do $key = $i; all you're doing is updating the copy, not the original array.

Use array_values($arr) instead, or use sort() instead of asort()