ChaosXero Posted August 13, 2006 Share Posted August 13, 2006 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 = 1I 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. Link to comment https://forums.phpfreaks.com/topic/17444-assoc-array-name-printing/ Share on other sites More sharing options...
trq Posted August 13, 2006 Share Posted August 13, 2006 Does this help?[code=php:0]foreach ($error as $k => $v) { if ($k == 'username' && $v == 1) { echo "Bad $k!"; }}[/code] Link to comment https://forums.phpfreaks.com/topic/17444-assoc-array-name-printing/#findComment-74260 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.