Created
May 22, 2013 00:56
-
-
Save tattyamm/5624470 to your computer and use it in GitHub Desktop.
連想配列を、キーの文字数が長い順に降順でソートする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sortByKeyLengthDesc($arr){ | |
$keys = array_map('strlen', array_keys($arr)); | |
array_multisort($keys, SORT_DESC, $arr); | |
return $arr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment