How to extract common words from two valiables in core php

$a=I love India.
$b=India is my country.

      

in core php, how can you extract a common word from these two variables.

+3


source to share


1 answer


try this, live demo



$a='I love India';
$b='India is my country';
print_r(array_intersect(explode(' ', $a), explode(' ', $b)));

      

+4


source







All Articles