2013-08-22 22 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);