note 59900 deleted from function.array-multisort by cmb

From: Date: Sun, 29 Sep 2019 07:41:56 +0000
Subject: note 59900 deleted from function.array-multisort by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-212412@lists.php.net to get a copy of this message
Note Submitter: phu at kungphu ---- Notepad's example using asort/arsort will -not- work unless 'points' is defined -before- 'name'. Running the posted code sorts by 'name', which was not the point of the previous posts. Defining 'points' as 'apoints' also did not work; however, defining 'points' first yields correct sorting: $test[0]['points']=1; $test[0]['name']='Peter'; $test[1]['points']=5; $test[1]['name']='Mike'; $test[2]['points']=2; $test[2]['name']='John'; asort($test); It appears asort uses the first defined element to sort a multidimensional array.

« previous php.notes (#212412) next »