答案 0 :(得分:2)
使用substr_count()
<?php
$mail = 'Hello, I want to find this letter, I have not received. Waiting for you to resend the letter.';
$keywords = array(
'letter',
'not received'
);
foreach($keywords as $keyword) {
echo "Keyword '$keyword': found " . substr_count($mail, $keyword) . "\n";
}
输出
关键字'字母':找到2
关键字'未收到':找到1