Description
int
stripos ( string haystack, string needle [, int offset])
Returns the numeric position of the first occurrence of
needle in the haystack
string_ Unlike strpos(),
stripos() is case_insensitive_
Note that the needle may be a string of one or
more characters_
If needle is not found,
stripos() will return boolean FALSE_
| Aviso |
Esta función
puede devolver FALSE, pero también puede devolver un valor
no_booleano que será evaluado FALSE, como por ejemplo
0 o ""_ Por favor, lea la sección
Booleans para más
información_ Utilice el operador === para
comprobar el valor devuelto por esta
función_ |
Ejemplo 1_ stripos() examples <?php
$findme = 'a';
$mystring1 = 'xyz';
$mystring2 = 'ABC';
$pos1 = stripos($mystring1, $findme);
$pos2 = stripos($mystring2, $findme);
// Nope, 'a' is certainly not in 'xyz'
if ($pos1 === false) {
echo "The string '$findme' was not found in the string '$mystring1'";
}
// Note our use of ===_ Simply == would not work as expected
// because the position of 'a' is the 0th (first) character_
if ($pos2 !== false) {
echo "We found '$findme' in '$mystring2' at position $pos2";
}
?> |
|
If needle is not a string, it is converted
to an integer and applied as the ordinal value of a character_
The optional offset parameter allows you
to specify which character in haystack to
start searching_ The position returned is still relative to the
the beginning of haystack_
See also strpos(), strrpos(),
strrchr(), substr(),
stristr(), strstr(),
strripos() and str_ireplace()_