Wednesday, June 12, 2013

Looping Through Associative Array - PHP

http://stackoverflow.com/questions/1951690/php-how-to-loop-through-a-associative-array-and-get-the-key-name

This was totally not very intuitive. I was expecting something like this:

foreach($array as $sub) {
echo(key($sub));
}

Instead, it's this:

foreach ($decodedOutput as $key => $value) {
echo $key;
}

No comments:

Post a Comment