再次原諒我的noobness。我有一個數組,其中有20個以上的值,我將每20個數據庫放在我的數據庫中,然後將它們從陣列的前面切下。我想重新啓動數組的索引返回到0,而是從20開始,即使我使用array_values。我也試過array_merge(array(),$ string)該怎麼辦?PHP重新索引數組?
if($x%20 == 0){
var_dump($string) // original array
get_string($string, $body, $binary); //puts the 20 string into my db
for($y=0; $y <20; $y++) //done with the 20 so I'm removing them
unset($string[$y]);
array_values($string); //reindex set $string[20] to $string[0] PLEASE!
var_dump($string); // this is suppose to be reindexed
}
相反,我得到
array // original array
0 => string '----' (length=25)
1 => string '----' (length=15)
2 => string '----' (length=27)
3 => string '----' (length=22)
4 => string '----' (length=23)
5 => string '----' (length=21)
6 => string '----' (length=26)
7 => string '----' (length=23)
8 => string '----' (length=24)
9 => string '----' (length=31)
10 => string '----' (length=19)
11 => string '----' (length=22)
12 => string '----' (length=24)
13 => string '----' (length=24)
14 => string '----' (length=25)
15 => string '----' (length=12)
16 => string '----' (length=16)
17 => string '----' (length=15)
18 => string '----' (length=23)
19 => string '----' (length=15)
20 => string '----' (length=16)
21 => string '----' (length=27)
array //reindexed array? This was suppose to be [0] and [1]
20 => string '----' (length=16)
21 => string '----' (length=27)
想我今晚太多了編程。非常感謝你 – Chenelle 2010-12-09 00:36:40