Forum Moderators: coopster
if(preg_match(..) ¦¦ preg_match(..) ¦¦ preg_match(..))
$subjects = array(
'My favorite pet is a cat.',
'My favorite pet is a snake.',
'My favorite pet is a bird.'
);
$pattern = '/\s([a-z]+)\.$/';
print '<pre>';
foreach ($subjects as $subject) {
if (preg_match($pattern, $subject, $matches)) {
print "Do you have a {$matches[1]}?\n";
}
}
print '</pre>';