stristr
(PHP 4, PHP 5, PHP 7, PHP 8)
stristr —
Versione insensibile alle maiuscole/minuscole di strstr()
Descrizione
Se needle
non viene trovato, la funzione restituisce false
.
Se needle
non è una stringa, viene convertito in
un intero e si utilizza il valore ordinale del carattere.
Example #1 Esempio di uso di stristr()
<?php
$email = 'USER@EXAMPLE.com';
echo stristr($email, 'e');
// outputs ER@EXAMPLE.com
?>
Example #2 Verifica se una stringa esiste o meno
<?php
$string = 'Hello World!';
if(stristr($string, 'earth') === FALSE) {
echo '"earth" not found in string';
}
// outputs: "earth" not found in string
?>
Example #3 Utilizzo di un dato non stringa da cercare
<?php
$string = 'APPLE';
echo stristr($string, 97); // 97 = lowercase a
// outputs: APPLE
?>
Nota: Questa funzione è
binary-safe (gestisce correttamente i file binari)
Vedere anche
strstr(),
strrchr(),
substr() e
ereg().