note 116718 added to function.sort

From: Date: Thu, 19 Feb 2015 04:21:32 +0000
Subject: note 116718 added to function.sort
Groups: php.notes 
Request: Send a blank email to php-notes+get-201739@lists.php.net to get a copy of this message
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 ---- Server IP: 72.52.91.14 Probable Submitter: 108.201.101.86 ---- Manual Page -- http://php.net/manual/en/function.sort.php Edit -- https://master.php.net/note/edit/116718 Del: integrated -- https://master.php.net/note/delete/116718/integrated Del: useless -- https://master.php.net/note/delete/116718/useless Del: bad code -- https://master.php.net/note/delete/116718/bad+code Del: spam -- https://master.php.net/note/delete/116718/spam Del: non-english -- https://master.php.net/note/delete/116718/non-english Del: in docs -- https://master.php.net/note/delete/116718/in+docs Del: other reasons-- https://master.php.net/note/delete/116718 Reject -- https://master.php.net/note/reject/116718 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#201739) next »