把数组按值的长度排序
bailing 2007-01-09
//把数组按值的长度排序
function arsortByLen(&$arr , $mode="ASC" )
{
foreach( $arr as $k=>$v)
{
$len[$k] = strlen($v);
}
if( $mode=="ASC" )
asort($len);
elseif( $mode=="DESC" )
arsort($len);
foreach( $len as $k=>$v)
{
$newarr[] = $arr[$k];
}
$arr = $newarr;
}
function arsortByLen(&$arr , $mode="ASC" )
{
foreach( $arr as $k=>$v)
{
$len[$k] = strlen($v);
}
if( $mode=="ASC" )
asort($len);
elseif( $mode=="DESC" )
arsort($len);
foreach( $len as $k=>$v)
{
$newarr[] = $arr[$k];
}
$arr = $newarr;
}