strstr
strstr
Find the first occurrence of a string
**strstr** string $haystack string $needle bool $before_needle
Returns part of string starting from and including the first
occurrence of to the end of
.
haystack``needle``haystack
Opmerking: > This function is case-sensitive. For case-insensitive searches, use .
stristr
Opmerking: > If it is only required to determine if a particular occurs within , the faster and less memory intensive function should be used instead.
needle``haystack``str_contains
haystackThe input string.
needleThe string to search for.
before_needle
If true, returns
the part of the before the first
occurrence of the (excluding the needle).
strstr``haystack``needle
Returns the portion of string, or false if
is not found.
needle
Voorbeeld: example
<?php
$email = 'name@example.com';
$domain = strstr($email, '@');
echo $domain, PHP_EOL; // prints @example.com
$user = strstr($email, '@', true);
echo $user, PHP_EOL; // prints name
?>
stristr``strrchr``strpos``strpbrk``preg_match