Forum und email

stristr

(PHP 4, PHP 5)

stristr — Versione insensibile alle maiuscole/minuscole di strstr()

Descrizione

string stristr ( string $haystack , string $needle )

Restituisce il contenuto di haystack dalla prima occorrenza di needle fino alla fine. needle e haystack sono esaminati senza distinguere tra lettere maiuscole e minuscole.

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 
'[email protected]';
  echo 
stristr($email'e');
// outputs [email protected]
?>

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($string97); // 97 = lowercase a
// outputs: APPLE
?>

Nota: Questa funzione è binary-safe (gestisce correttamente i file binari)

Vedere anche strstr(), strrchr(), substr() e ereg().