我希望生成一个字符串,如' A00021' ,长度的数量是5,当数字是10000以上那么字符串就像' B00001',如何生成这样的字符串?
答案 0 :(得分:0)
它可能对你有帮助......
$str = "A10000";
if(substr($str,-5) >= '10000'){
$newstr = strtoupper(chr(ord(substr($str,0,1)) + 1))."00001";
}else{
$newstr = substr($str,0,1).substr("00000".(substr($str,-5)+1),-5);
}
echo $newstr;