mb_strstr
(PHP 5 >= 5.2.0, PHP 7, PHP 8)
Finds first occurrence of a string within another
Description
mb_strstr() finds the first occurrence of needle in haystack and returns the portion of haystack. If needle is not found, it returns false.
Parameters
haystackThe string from which to get the first occurrence of
needleneedleThe string to find in
haystackbefore_needleDetermines which portion of
haystackthis function returns. If set to true, it returns all ofhaystackfrom the beginning to the first occurrence ofneedle(excluding needle). If set to false, it returns all ofhaystackfrom the first occurrence ofneedleto the end (including needle).encodingParameter
Return Values
Returns the portion of haystack, or false if needle is not found.
Changelog
| Version | Description |
|---|---|
| 8.3.2 | On invalid strings (those with encoding errors) and on SJIS-mac (MacJapanese) strings, the portion of haystack returned when before_needle is true is now determined from the same character indices as the other mbstring functions. |