how to check if a string contains a substring in php
snippet in php

how to check if a string contains a substring in php

user3551

$a = 'How are you?';

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

if text contains word then in php

user5258

if (strpos($haystack,$needle) !== false) {
    echo "$haystack contains $needle";
}