strripos
strripos
Find the position of the last occurrence of a case-insensitive substring in a string
**strripos** string $haystack string $needle int $offset
Find the numeric position of the last occurrence of
in the string.
needle``haystack
Unlike the , is
case-insensitive.
strrpos``strripos
haystackThe string to search in.
needleThe string to search for.
offset
If zero or positive, the search is performed left to right skipping the
first bytes of the
.
offset``haystack
If negative, the search is performed right to left skipping the
last bytes of the
and searching for the first occurrence
of .
`offset``haystack``needle`> **Opmerking:** > This is effectively looking for the last occurrence of
before the last bytes. `needle``offset`
Returns the position where the exists relative to the beginning of the string (independent of search direction or ).
needle``haystack``offset> Opmerking: > String positions start at 0, and not 1.
Returns false if the was not found.
needle
-
If is greater than the length of , a will be thrown.
offset``haystack``ValueErrorVoorbeeld: A simple example
<?php
$haystack = 'ababcd';
$needle = 'aB';
$pos = strripos($haystack, $needle);
if ($pos === false) {
echo "Sorry, we did not find `$needle` in `$haystack`";
} else {
echo "Congratulations!\n";
echo "We found the last `$needle` in `$haystack` at position `$pos`";
}
?>
Congratulations!
We found the last `aB` in `ababcd` at position `2`
strpos``stripos``strrpos``strrchr``stristr``substr