Hi friends am trying to compare n sentences in an array and get the common words which are present in more than one sentence. Here is sample
$cars=("hello how","hello when","when you came",........,n sentences);
array_intersect is used to compare 2 or 3 arrays which have exactly common words in all the three can anyone help me with these
$cars = array_filter(
array_count_values(
array_merge(
...array_map(
function($x) { return array_unique(explode(' ', $x));},
$cars))),
function($x) { return $x > 1; });
print_r($cars);
Step by step