Function sort_by _length($aar,$bbr)
{
$alen = strlen($arr);
$blen = strlen($brr);
if ($alen == $blen) {
return 0;
}
return ($alen > $blen) ? -1 : 1;
}
Call it with
usort($myarr,'sort_by_length');
Where $myarr is the array to sort. If it sorts in the wrong direction, you can either do an array_reverse(), or flip flop the 1, and -1 return values in the function.