note 116718 deleted from function.sort by salathe

From: Date: Thu, 19 Feb 2015 16:40:53 +0000
Subject: note 116718 deleted from function.sort by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-201758@lists.php.net to get a copy of this message
Note Submitter: simon dot rodan at sjsu dot edu ---- sort appears to discard keys... $an_array['C'] = "the letter C"; $an_array['B'] = "the letter B"; $an_array['A'] = "the letter A"; echo "Before sorting...<br><br>"; foreach ($an_array as $key => $element) { echo "\$an_array[$key] = $an_array[$key] <br>"; } echo "<br>"; sort($an_array); echo "After sorting...<br><br>"; foreach ($an_array as $key => $element) { echo "\$an_array[$key] = $an_array[$key] <br>"; } Gives this output: Before sorting... $an_array[C] = the letter C $an_array[B] = the letter B $an_array[A] = the letter A After sorting... $an_array[0] = the letter A $an_array[1] = the letter B $an_array[2] = the letter C

« previous php.notes (#201758) next »