Page 1 of 1

array sorting

Posted: Mon Aug 15, 2005 6:59 am
by shiznatix
i need to sort an array by the amount of characters in the value. how would i go about doing that

Posted: Mon Aug 15, 2005 7:18 am
by feyd
entirely untested

Code: Select all

$temp = array_map('strlen',$array);
asort($temp);
$new = array();
foreach($temp as $k => $blah)
{
  $new[$k] = $array[$k];
}

Posted: Mon Aug 15, 2005 8:08 am
by shiznatix
thanks feyd works perfect