您好,我正在循环一个数组,例如:
Array
(
[01/04/2013 - 14:54] => Array
(
[0] => 13528
[1] => status
[2] => Waiting
[3] => 10000
[4] => Message to user
[5] => Message3 to my dear user
)
[01/04/2013 - 14:14] => Array
(
[0] => 13523
[1] => status
[2] => Waiting
[3] => 10000
[4] => Message to user
[5] => Message2 to my dear user
)
[12/20/2012 - 09:13] => Array
(
[0] => 13476
[1] => status
[2] => Waiting
[3] => 10000
[4] => Message to user
[5] => Message do my dear user
)
);
我需要的是正确显示它以避免重复:这是我的代码。
foreach ($histories_by_date as $date => $events) {
$output .= $date;
foreach ($events as $key => $event) {
switch ($events[$key]) {
case 'Message from user':
$output .= $events[$key + 1];
break;
case 'Message to user':
$output .= $events[$key + 1];
break;
}
}//foreach2
}//foreach1
令人讨厌的是我得到了重复,例如:
01/04/2013 - 14:54 (CET)
Message3 to my dear user
01/04/2013 - 14:14 (CET)
Message3 to my dear user
Message2 to my dear user
12/20/2012 - 09:13 (CET)
Message3 to my dear user
Message2 to my dear user
Message do my dear user
我只需要在原始数组中显示。