You can use the php usort
method, check it out here
with usort
you can implement your custom compare to
function and sort the array according to it.
the custom compare to
function is int callback ( mixed $a, mixed $b )
, you should return a value less than 0 if $a < $b
, zero if equal and a value bigger than 0 when $a > $b
implement your preferred order of sorting using this method
example:
function cmp($a, $b) {
$aTemp = str_replace('_', '0', $a);
$bTemp = str_replace('_', '0', $b);
return strcmp($aTemp,$bTemp);
}
usort($arr, "cmp");
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…