我有一个数组($vEvents)
如下:
Array
(
[0] => Array
(
[id] => 1174
[date] => 120411
[name] => DR. J 'Souled Out' ~ 9pm (No Cover)
[pubId] => 44
[price] =>
)
[1] => Array
(
[id] => 1108
[date] => 120410
[name] => Verb presents Open Stage ~ 9pm (No Cover)
[pubId] => 44
[price] =>
)
[2] => Array
(
[id] => 1104
[date] => 120409
[name] => DR. J 'Souled Out' ~ 9pm (No Cover)
[pubId] => 44
[price] =>
)
[currLimit] => 10
[eventsRemaining] => 4
我在屏幕上回显它:
reset ($vEvents);
foreach ($vEvents as $key => &$value) {
if ($key != 'currLimit' && $key != 'eventsRemaining'){ //Makes sure it doesn't print out the limiter value
$m = substr($value['date'],0,2);
$d = substr($value['date'],2,2);
$y = '20'.substr($value['date'],4,2);
echo date("D", mktime(0, 0, 0, $m, $d, $y)).", ".date("M", mktime(0, 0, 0, $m, $d, $y))." ".$d.", ".$y." - ".$value['name'].'<br />';
}
}
但是在我的输出中,它没有得到所有显示的数组条目,而是一直跳过第一个......输出:
Sat, Dec 04, 2010 - Verb presents Open Stage ~ 9pm (No Cover)
Fri, Dec 04, 2009 - DR. J 'Souled Out' ~ 9pm (No Cover)
但是,我的预期输出应该是:
Sun, Dec 04, 2011 - DR. J 'Souled Out' ~ 9pm (No Cover)
Sat, Dec 04, 2010 - Verb presents Open Stage ~ 9pm (No Cover)
Fri, Dec 04, 2009 - DR. J 'Souled Out' ~ 9pm (No Cover)
我曾尝试更改name
键中的值等,但所有其他整个显示都很好,它总是跳过第一个键。我以前从未遇到过这个问题。想法?
当我注释掉:if ($key != 'currLimit' && $key != 'eventsRemaining'){ //Makes sure it doesn't print out the limiter value
行时,它工作正常。第一个元素的键为零是否相关?但是为什么我的if
检查会失败呢?