<?php
$myarray = [ "aa", "bbb", "c", "dddddd", "eeee"];
usort($myarray, 'sortbylength' );
function sortbylength($a,$b){
return strlen($b)-strlen($a);
}
echo "<pre>";
print_r( $myarray );
?>
Output:
Array (
[0] => dddddd
[1] => eeee
[2] => bbb
[3] => aa
[4] => c
)
Neuen Kommentar schreiben