How do I check if a string contains a specific word in PHP?

You can use the strpos function which is used to find the occurrence of one string inside other:

Example

$a = 'How are you?';

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

Output

true
Share

You may also like...