keys re-ordered after array_pop()

From: Date: Thu, 05 Oct 2000 20:26:53 +0000
Subject: keys re-ordered after array_pop()
Groups: php.general 
Request: Send a blank email to php-general+get-18764@lists.php.net to get a copy of this message
Hi all, This one had me going for awhile. Is this a "feature" or am I really missing something? I've created a form where people can create a user profile by answering a questionnaire. Some answers are single choice (radio), others are multiple choice (checkboxes). Any question may be skipped. The "name" field is generated this way: if( "radio" == $type ) { // for single answers $name = $question_number } else { // for multiple answers $name = $question_number[$answer_number] } Walking the array using list() = each( $HTTP_POST_VARS ) a typical output may look like this ( question -> answer ): 1 -> 3 2 -> 7 4 -> 9 4 -> 10 4 ->13 7 -> 22 which is what I expected. However, after issuing this: $stuff = array_pop( $HTTP_POST_VARS ) and rewalking through the array I see this: 0 -> 3 1 -> 7 2 -> 9 3 -> 10 4 -> 13 I've now lost the associated question numbers. Could someone shed some light on this or point me to the appropriate place in the docs? I'm really puzzled. ( Please cc me. I'm on the newslist, not maillist ) Thanks in advance, Mike Wright

« previous php.general (#18764) next »