適用php版本(PHP 8 >= 8.3.0)
str_increment — 遞增字母數字字串
說明
str_increment(string $string): string
返回遞增的字母數字ASCII字串。
引數
string
The input string.
返回值
返回遞增的字母數字ASCII字串。
錯誤/異常
如果string為空,則丟擲ValueError。
如果字串不是字母數字ASCII字串,則丟擲ValueError。
示例 ¶
示例 #1 Basic str_increment() example
<?php
$str = 'ABC';
var_dump(str_increment($str));
?>
以上示例會輸出:
string(3) "ABD"
示例 #2 str_increment() example with a carry
<?php
$str = 'DZ';
var_dump(str_increment($str));
$str = 'ZZ';
var_dump(str_increment($str));
?>
以上示例會輸出:
string(2) "EA"
string(3) "AAA"