- print_r: documentation ( source)
- preg_match_all: documentation ( source)
- implode: documentation ( source)
<?php
$sentence = "This is a red apple";
$words = array('red','apple');
$ch = implode("|",$words);
$pattern = "/($ch)/";
if(preg_match_all($pattern, $sentence,$m))
{
echo "yes \n";
print_r($m);
}