如何删除assocative数组键并添加默认的数组键PHP ?

时间:2021-03-24 10:49:26
$arr = array(3=>'test',6=>'test 2');

i want to make it

我想去

$arr = array(0=>'test',1=>'test 2'); 

what is the best way . is there any php function to do that .

最好的办法是什么?有没有php函数可以做到这一点。

thanks in advance

谢谢提前

1 个解决方案

#1


4  

Simply use array_values :

简单地使用元素:

$arr = array(3=>'test',6=>'test 2');
$arr = array_values($arr);

http://www.php.net/manual/en/function.array-values.php

http://www.php.net/manual/en/function.array-values.php

#1


4  

Simply use array_values :

简单地使用元素:

$arr = array(3=>'test',6=>'test 2');
$arr = array_values($arr);

http://www.php.net/manual/en/function.array-values.php

http://www.php.net/manual/en/function.array-values.php