php find if string contains
snippet in php

php find if string contains

user7695

if (strpos($string, 'substring') !== false) {
	// do stuff 
}

if part of stringp ph

user5349

$a = 'How are you?';

if (strpos($a, 'are') !== false) {
    echo 'true';
}

php check if string contains

user9597

// returns true if $needle is a substring of $haystack
function contains($haystack, $needle){
    return strpos($haystack, $needle) !== false;
}