How can find match word position inside the string in php


How can used strpos function with if condition

How can match particular word inside the string 

How can used contains in if else condition in php

with example

Use of strpos function, if you can find position of particuler word,

if match the particular word in side the string 

$b = 'How can you?';

if ($b contains 'can')

    echo 'true yes';

$b = 'How can you?';

if (strpos($b, 'can') !== false) {

    echo 'true yes';

$b = 'How can you?';

if (preg_match('/are/',$b))

    echo 'true yes';

you can also used this type


$st = 'how can you';

$mt = 'can';

if (strpos($st,$mt) !== false) {

    echo 'yes';