str_increment
(PHP 8 >= 8.3.0)
str_increment — Increment an alphanumeric string
Параметри
string
-
The input string.
Значення, що повертаються
Returns the incremented alphanumeric ASCII string.
Помилки/виключення
A ValueError is thrown if
string is empty.
A ValueError is thrown if
string is not an alphanumeric
ASCII string.
Приклади
Приклад #1 Basic str_increment() example
<?php
$str = 'ABC';
var_dump(str_increment($str));
?>
Поданий вище приклад
виведе:
Приклад #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"