I have an array ($vEvents) as follows:
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
I am echoing it to the screen with:
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 />';
}
}
But on my output, instead of getting all displayed array entries, it keeps skipping the first one… Output:
Sat, Dec 04, 2010 - Verb presents Open Stage ~ 9pm (No Cover)
Fri, Dec 04, 2009 - DR. J 'Souled Out' ~ 9pm (No Cover)
However, my expected output should be:
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)
I have tried changing the values in the name key and such, but all other entire show fine, it just always skips the first key. I have never had this issue before. Thoughts?
When I comment out the:if ($key != 'currLimit' && $key != 'eventsRemaining'){ //Makes sure it doesn't print out the limiter value line, it works fine. Is it relevant that the key of the first element is zero? But why would that fail my if check?
PHP is weird when it deals with values of 0… it treats them as false in most cases. So,
is going to evaluate to false when $key == 0. I would change it to: