我想生成一个像'A00021'这样的字符串,长度为5,当数字大于10000时,那么像'B00001'这样的字符串,如何生成这样的字符串?
It might help you...
$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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.