// 查询苹果系列的产品
$str = 'ipad,iphone,imac,ipod,iamsorry';
$patt = '/\bi(pad|phone|mac|pod)\b/';
preg_match_all($patt,$str,$res);
print_r($res);
// Array ( [0] => Array ( [0] => ipad [1] => iphone [2] => imac [3] => ipod ) [1] => Array ( [0] => pad [1] => phone [2] => mac [3] => pod ) )