note 54867 deleted from function.array-multisort by cmb

From: Date: Sun, 29 Dec 2019 10:27:23 +0000
Subject: note 54867 deleted from function.array-multisort by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213679@lists.php.net to get a copy of this message
Note Submitter: AlberT at SuperAlberT dot it ---- a nice piece of code to do an "array_key_multi_sort()" is the following: <?php /** * orders a multidimentional array on the base of a label-key * * @param $arr, the array to be ordered * @param $l the "label" identifing the field * @param $f the ordering function to be used, * strnatcasecmp() by default * @return TRUE on success, FALSE on failure. */ function array_key_multi_sort(&$arr, $l , $f='strnatcasecmp') { return usort($arr, create_function('$a, $b', "return $f(\$a['$l'], \$b['$l']);")); } ?>

« previous php.notes (#213679) next »