Forum Moderators: coopster
eg... here is my current array
array[0] = the dog was lazy
array[1] = the lazy dog
array[3] = wow that dog sure is lazy
I would like it to re-order as follows:
array[0] = wow that dog sure is lazy
array[1] = the dog was lazy
array[2] = the lazy dog
Any assistance, greatly appreciated.
function cmp($a, $b)
{
$a = strlen($a);
$b = strlen($b);
if ($a == $b) {
return 0;
}
return ($a > $b) ? -1 : 1;
}
$array[0] = 'the dog was lazy';
$array[1] = 'the lazy dog';
$array[3] = 'wow that dog sure is lazy';
print_r($array);
usort [php.net]($array, 'cmp');
print_r($array);