How to find a specific word in a string in PHP

0
70

Use the strpos function

$word_string = "Apple Mango Banana";
$find   = "Banana";

if( strpos( $word_string, $find ) !== false) {
    echo "Exists"
}

This helps to check string contains a specific word.

LEAVE A REPLY

Please enter your comment!
Please enter your name here