开发者

How do I reassign array positions in php? [duplicate]

开发者 https://www.devze.com 2023-03-28 09:47 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: How to re-index the values of an array in PHP?
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

How to re-index the values of an array in PHP?

I'm using several php functions to carry c开发者_StackOverflow中文版ertain data over through an array, and through the process I get arrays that print_r like the following:

Array ([0] => 35 [4] => 36 [6] => 34)

What do I have to do if I want to reorder it back to the following? (I use a for statement and need the keys to be in consecutive order starting from 0 again)

Array ([0] => 35 [1] => 36 [2] => 34)


$array = array_values($array);
0

精彩评论

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