Jump to content

Archived

This topic is now archived and is closed to further replies.

ChaosXero

Assoc Array name printing

Recommended Posts

I have an array I'm using for errors and I'd like it to output the name of the array section i.e.

array error() =
    username = 1

I want to output

Bad 'Username!' (told to do so because username = 1)

I just need to know what to do to output the 'name' of an item in an array.  Hope this makes sense.

Share this post


Link to post
Share on other sites
Does this help?

[code=php:0]
foreach ($error as $k => $v) {
  if ($k == 'username' && $v == 1) {
    echo "Bad $k!";
  }
}
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.