// Sort an array by the length of its values? usort($array, function($a, $b) { return strlen($b) - strlen($a); }); // http://stackoverflow.com/questions/838227/php-sort-an-array-by-the-length-of-its-values