note 105399 modified in function.ksort by danbrown
| From: | danbrown@php.net | Date: | Mon, 15 Aug 2011 16:31:52 +0000 |
| Subject: | note 105399 modified in function.ksort by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-182494@lists.php.net to get a copy of this message | ||
Here is a function to recursively sort multidimentional arrays by key:
<?php
function deep_ksort(&$arr) {
ksort($arr);
foreach ($arr as &$a) {
if (is_array($a) && !empty($a)) {
deep_ksort($a);
}
}
}
?>
--was--
Here is a function to recursively sort multidimentional arrays by key:
function deep_ksort(&$arr) {
ksort($arr);
foreach ($arr as &$a) {
if (is_array($a) && !empty($a)) {
deep_ksort($a);
}
}
}
http://php.net/manual/en/function.ksort.php