phpday 2027 - Call for Papers

str_decrement

(PHP 8 >= 8.3.0)

str_decrement — Decrementa una stringa alfanumerica

Descrizione

function str_decrement(string $string): string

Restituisce la stringa ASCII alfanumerica string decrementata.

Elenco dei parametri

string

La stringa di input.

Valori restituiti

Restituisce la stringa ASCII alfanumerica decrementata.

Errori/Eccezioni

Viene lanciato un ValueError se string è vuota.

Viene lanciato un ValueError se string non è una stringa ASCII alfanumerica.

Viene lanciato un ValueError se string non può essere decrementata. Ad esempio, "A" o "0".

Esempi

Example #1 Esempio base di str_decrement()

<?php
$str = 'ABC';
var_dump(str_decrement($str));
?>

Il precedente esempio visualizzerà:

string(3) "ABB"

Example #2 Esempio di str_decrement() con riporto

<?php
$str = 'ZA';
var_dump(str_decrement($str));

$str = 'AA';
var_dump(str_decrement($str));
?>

Il precedente esempio visualizzerà:

string(2) "YZ"
string(1) "Z"

Vedere anche:

+add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top