PHP.nl

str_decrement

str_decrement

Decrement an alphanumeric string

string **str_decrement** string $string

Returns the decremented alphanumeric . string

stringThe input string.

Returns the decremented alphanumeric string.

A is thrown if is empty. ValueError``string

A is thrown if is not an alphanumeric string. ValueError``string

A is thrown if cannot be decremented. For example, or . ValueError``string``"A"``"0"

Voorbeeld: Basic example

<?php
$str = 'ABC';
var_dump(str_decrement($str));
?>
string(3) "ABB"

Voorbeeld: 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"

str_increment