public function tes()
{
$a = 'abcd12345ed125ss123456789988888';
$pattern = '/[D]+/';
$numberStrs = preg_split($pattern, $a, null, PREG_SPLIT_NO_EMPTY);
dump($numberStrs);
function lengthSort($a, $b)
{
if (strlen($a) == strlen($b)) return 0;
return (strlen($a) < strlen($b)) ? -1 : 1;
}
//
usort($numberStrs, 'lengthSort');
$longestStr = end($numberStrs);
var_dump($longestStr);
}
数组排序
$v['date']为要排序的字段
foreach($newsw as $key=>$val){
$new_array= array();
$sort_array = array();
foreach($val as $k=>$v){
$sort_array[$k] = $v['date'];
}
asort($sort_array);
reset($sort_array);
foreach($sort_array as $k=>$v){
$new_array[$k] = $newsw[$key][$k];
}
$newsw[$key] = $new_array;
}