Check if String exists in String

Knowledge Base Entry: #58
^Top
<< Back
Mobile-Menu










Check if String exists in String
Category: PHP/Snippets
Author: Bugfish
Created at: 2020-11-07 16:04:34
Modified at: 2025-09-19 17:26:04
Directs Hits: 679

 Here code to check if a string exists in another string!

$string = 'This is a String';
if (strpos($string , 'This') !== false) {
    echo 'true'; # STRING CONTAINS WORD "This"
} else {
# String not found inside $string
}

 

Caution: I do not guarantee the reliability of the information given here, the code described on this page is executed at your own risk and in the event of damage or other unforeseeable consequences I am in no way responsible or liable.
This Website is using Session Cookies for Site Functionality.