note 79491 deleted from function.array-multisort by cmb
| From: | cmb@php.net | Date: | Sun, 29 Sep 2019 07:48:06 +0000 |
| Subject: | note 79491 deleted from function.array-multisort by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212422@lists.php.net to get a copy of this message | ||
Note Submitter: glenn at freebsd dot nl
----
To sort a nested array by column (key/index):
Example: two entries in the nested array:
firstarray[0]['adres'] = "adres1"
firstarray[0]['email'] = "email2"
firstarray[1]['adres'] = "adres2"
firstarray[1]['email'] = "email1"
-----------------------------------------
Without code: output would put adres1/email2 on top
-----------------------------------------
foreach($firstarray as $sortarray)
{
$column[] = $sortarray['email'];
array_multisort($column, SORT_ASC, $firstarray);
}
-----------------------------------------
With code: output would put adres2/email1 on top