note 115440 deleted from function.krsort by salathe
| From: | salathe@php.net | Date: | Mon, 04 Aug 2014 08:45:03 +0000 |
| Subject: | note 115440 deleted from function.krsort by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-200097@lists.php.net to get a copy of this message | ||
Note Submitter: marcus at synchromedia dot co dot uk
----
Note that you can sort subarrays within a larger structure without sorting the whole thing:
<?php
$fruits = array("d"=>"lemon", "a"=>"orange",
"b"=>"banana", "c"=>"apple", 'e' =>
array("d"=>"lemon", "a"=>"orange",
"b"=>"banana", "c"=>"apple"));
krsort($fruits['e']);
var_dump($fruits);
?>
array(5) {
["d"]=>
string(5) "lemon"
["a"]=>
string(6) "orange"
["b"]=>
string(6) "banana"
["c"]=>
string(5) "apple"
["e"]=>
array(4) {
["d"]=>
string(5) "lemon"
["c"]=>
string(5) "apple"
["b"]=>
string(6) "banana"
["a"]=>
string(6) "orange"
}
}
You can see that it only sorts the items within the 'e' element.