开发者

PHP remove non-existing indexes from array and rearrange [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

php array re populate keys

is there a way to remove all the non-existing indexes from a php array and then rearrange it? For example

Array
(
    [0] => a
    [2] => b
    [3] => c
    [6] => d
)

TO

Array
(
    [0] => a
    [开发者_Go百科1] => b
    [2] => c
    [3] => d
)

Big thanks! Rik.


Just use this built-in function

$array=array_values($array)


Use array_values.

$arr = array_values($arr);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜