Paul's Programming Notes
PostsRSSGithub

Looping Through Associative Array - PHP

13 Jun 2013

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;
}
php

Related posts

  • Include Array From File - PHP 29 Jun 2013
  • move_uploaded_file To Current Path - PHP 29 Jun 2013
  • WHMCS Hook - Trigger E-mail On New User Sign-Up 28 Jul 2013
© 2026. All rights reserved.