note 125741 added to function.str-contains
| From: | me at daz dot co dot uk | Date: | Sat, 30 Jan 2021 13:26:08 +0000 |
| Subject: | note 125741 added to function.str-contains | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-219176@lists.php.net to get a copy of this message | ||
# Watch out for aberrant partial matches
$string = 'The lazy fox jumped over the fence';
if (str_contains($string, 'ox')) {
echo 'The string "ox" was found in the string because it was a partial
match';
} else {
echo '"ox" was not found';
}
//output: The string "ox" was found in the string because it was a partial match
# use spaces for full word matching
$string = 'The lazy fox jumped over the fence';
if (str_contains($string, ' ox ')) {
echo 'The string " ox " was found in the string because it was a partial
match';
} else {
echo '" ox " was not found';
}
//output: " ox " was not found
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.159.166 (proxied: 70.119.149.147)
----
Manual Page -- http://php.net/manual/en/function.str-contains.php
Edit -- https://master.php.net/note/edit/125741
Del: integrated -- https://master.php.net/note/delete/125741/integrated
Del: useless -- https://master.php.net/note/delete/125741/useless
Del: bad code -- https://master.php.net/note/delete/125741/bad+code
Del: spam -- https://master.php.net/note/delete/125741/spam
Del: non-english -- https://master.php.net/note/delete/125741/non-english
Del: in docs -- https://master.php.net/note/delete/125741/in+docs
Del: other reasons-- https://master.php.net/note/delete/125741
Reject -- https://master.php.net/note/reject/125741
Search -- https://master.php.net/manage/user-notes.php