In this article, We’ll see how we can check string contains a substring in php.
Below an example if string contains a substring, it will return true otherwise false.
$string = 'Hello World!'; $substring = 'Hello'; if (strpos($string, $substring) !== FALSE) { echo 'true'; } else { echo 'false'; }
That’s it!. Please share your thoughts or suggestions in the comments below.