php 按字母顺序排序数组然后按数字排序

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 按字母顺序排序数组然后按数字排序相关的知识,希望对你有一定的参考价值。

function myComparison($a, $b){
    if(is_numeric($a) && !is_numeric($b))
        return 1;
    else if(!is_numeric($a) && is_numeric($b))
        return -1;
    else
        return ($a < $b) ? -1 : 1;
} 
$test = array("def", "yz", "abc", "jkl", "123", "789", "stu");
usort ( $test , 'myComparison' );

以上是关于php 按字母顺序排序数组然后按数字排序的主要内容,如果未能解决你的问题,请参考以下文章