2013-08-22 23 views
-1

我需要按順序顯示陣列如何在PHP中按順序顯示數組的值?

my array 

Array 
(
[0] => [email protected] 
[1] => [email protected] 
[2] => [email protected] 
[3] => [email protected] 
[6] => [email protected] 
[7] => [email protected] 
[13] => [email protected] 
) 

我要像下面

Array 
(
[0] => [email protected] 
[1] => [email protected] 
[2] => [email protected] 
[3] => [email protected] 
[4] => [email protected] 
[5] => [email protected] 
[6] => [email protected] 
) 

輸出現在的問題是如何顯示陣列像PHP上述順序?

回答

4

使用array_values重新索引陣列

$array = array_values($array); 
+4

那麼答案已經給了ca.四年前左右。 – hakre

0

要顯示在序列中的值使用foreach循環作爲這樣

foreach($array as $arr){ 
echo $arr."\n"; 
} 

將值存儲與新索引或鍵使用

array_values($array);