Answers for "check if string exists"

PHP
65

php check if string contains word

$myString = 'Hello Bob how are you?';
if (strpos($myString, 'Bob') !== false) {
    echo "My string contains Bob";
}
Posted by: Guest on August-06-2019
11

python str contains word

fullstring = "StackAbuse"
substring = "tack"

if substring in fullstring:
    print "Found!"
else:
    print "Not found!"
Posted by: Guest on November-01-2020

Browse Popular Code Answers by Language