Jump to content


Photo

Assoc Array name printing


  • Please log in to reply
1 reply to this topic

#1 ChaosXero

ChaosXero
  • Members
  • PipPipPip
  • Advanced Member
  • 80 posts

Posted 13 August 2006 - 11:22 PM

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.

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 13 August 2006 - 11:58 PM

Does this help?

foreach ($error as $k => $v) {
  if ($k == 'username' && $v == 1) {
    echo "Bad $k!";
  }
}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users