note 47092 added to function.rsort

From: Date: Tue, 02 Nov 2004 15:49:58 +0000
Subject: note 47092 added to function.rsort
Groups: php.notes 
Request: Send a blank email to php-notes+get-79509@lists.php.net to get a copy of this message
Like sort(), rsort() assigns new keys for the elements in array. It will remove any existing keys you may have assigned, rather than just reordering the keys. This means that it will destroy associative keys. $animals = array("dog"=>"large", "cat"=>"medium", "mouse"=>"small"); print_r($animals); //Array ( [dog] => large [cat] => medium [mouse] => small ) rsort($animals); print_r($animals); //Array ( [0] => small [1] => medium [2] => large ) Use KSORT() or KRSORT() to preserve associative keys. ---- Manual Page -- http://www.php.net/manual/en/function.rsort.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+47092 Delete -- http://master.php.net/manage/user-notes.php?action=delete+47092&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47092&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47092&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47092&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47092&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47092&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+47092&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#79509) next »