2016-03-01 58 views
-3

我有可变$alldates,这与print_r给我带来了以下内容:获取数据

Array ([0] => Array ([0] => 24. May 2016 08:30 - 17:00 [1] => 7. June 2016 08:30 - 17:00)) 

我需要显示的日期在PDF(可以是很多两个以上),ordered下海誓山盟喜欢:

24. May 2016 08:30 - 17:00 
7. June 2016 08:30 - 17:00 

如何getarraydisplay他们dates

+1

你试过'foreach'吗? –

+1

请发布您到目前为止尝试过的代码。 – besciualex

回答

3
foreach ($alldates as $index){ 
    echo $index."<br/>"; 
} 

我不知道你的阵列,另一种方式:

foreach ($alldates[0] as $index){ 
    echo $index."<br/>"; 
} 
+3

这个问题有点不清楚,但OP可能需要循环:'foreach($ alldates [0]为$ index){'或使用嵌套循环。 – jeroen

+1

@ jeroen,你的权利。 – 2016-03-01 07:40:04

0

试试这个:

foreach ($alldates as $date) { 

    echo $date . '<br />'; 
} 

或THRE这里是另一种方式

$count = count($alldates); 

for ($i = 0; $i < $count; $i++) { 

    echo $alldates[i] . '<br />'; 
} 
0

如果它的多维ar可以使用嵌套循环ray像这样:

Array 
(
    [0] => Array 
     (
      [0] => 24. May 2016 08:30 - 17:00 
      [1] => 7. June 2016 08:30 - 17:00 
     ) 

    [1] => Array 
     (
      [0] => 24. May 2016 08:30 - 17:00 
      [1] => 7. June 2016 08:30 - 17:00 
     ) 

) 

foreach ($alldates as $s_date){  
    foreach ($s_date as $n_date){ 
     echo $n_date."<br/>"; 
    } 
}