Built-in PHP function to reset the indexes of an array?

前端 未结 4 939
悲哀的现实
悲哀的现实 2021-01-13 04:50

Example:

$arr = array(1 => \'Foo\', 5 => \'Bar\', 6 => \'Foobar\');
/*... do some function so $arr now equals:
    array(0 => \'Foo\', 1 => \'         


        
4条回答
  •  遥遥无期
    2021-01-13 04:57

    Use array_values($arr). That will return a regular array of all the values (indexed numerically).

    PHP docs for array_values

提交回复
热议问题