note 126556 added to function.uasort
| From: | tschallacka at lookingout dot com | Date: | Thu, 04 Nov 2021 11:42:04 +0000 |
| Subject: | note 126556 added to function.uasort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-217139@lists.php.net to get a copy of this message | ||
php > 7
Sorting associative array, by a value of a subarray.
<?php
uasort($items, function ($a, $b) {
if ($a['sort_order']??0 == $b['sort_order']??0) {
return 0;
}
return ($a['sort_order']??0 < $b['sort_order']??0) ? -1 : 1;
});
?>
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.85.242 (proxied: 94.168.97.250)
----
Manual Page -- https://php.net/manual/en/function.uasort.php
Edit -- https://main.php.net/note/edit/126556
Del: integrated -- https://main.php.net/note/delete/126556/integrated
Del: useless -- https://main.php.net/note/delete/126556/useless
Del: bad code -- https://main.php.net/note/delete/126556/bad+code
Del: spam -- https://main.php.net/note/delete/126556/spam
Del: non-english -- https://main.php.net/note/delete/126556/non-english
Del: in docs -- https://main.php.net/note/delete/126556/in+docs
Del: other reasons-- https://main.php.net/note/delete/126556
Reject -- https://main.php.net/note/reject/126556
Search -- https://main.php.net/manage/user-notes.php