适用php版本(PHP 8 >= 8.3.0)
str_decrement — 递减字母数字字符串
说明
str_decrement(string $string): string
返回自减的字母数字ASCII字符串。参数
string
The input string.
返回值
返回自减的字母数字ASCII字符串。
错误/异常
如果string为空,则抛出ValueError。
如果字符串不是字母数字ASCII字符串,则抛出ValueError。
如果字符串不能自减,则抛出ValueError。例如“A”或“0”。
示例
示例 #1 Basic str_decrement() example
<?php
$str = 'ABC';
var_dump(str_decrement($str));
?>
以上示例会输出:
string(3) "ABB"
示例 #2 str_decrement() example with a carry
<?php
$str = 'ZA';
var_dump(str_decrement($str));
$str = 'AA';
var_dump(str_decrement($str));
?>
以上示例会输出:
string(2) "YZ"
string(1) "Z"