@H_502_1@经测试代码如下:
/**
* 为数字增加 st\nd\rd
*
* @param
* @author 编程之家 jb51.cc jb51.cc
**/
function make_ranked($rank) {
$last = substr( $rank,-1 );
$seclast = substr( $rank,-2,-1 );
if( $last > 3 || $last == 0 ) $ext = 'th';
else if( $last == 3 ) $ext = 'rd';
else if( $last == 2 ) $ext = 'nd';
else $ext = 'st';
if( $last == 1 && $seclast == 1) $ext = 'th';
if( $last == 2 && $seclast == 1) $ext = 'th';
if( $last == 3 && $seclast == 1) $ext = 'th';
return $rank.$ext;
}
/*** 来自编程之家 jb51.cc(jb51.cc) ***/
原文链接:https://www.f2er.com/php/529090.html