我有一段代码在我的本地测试服务器上运行良好,但在实时服务器上由于某种原因它不能。实时服务器上的 PHP 版本是 5.1.6。
$subject = 'random words to check';
$terms = explode(' ', 'word1 word2 check');
$wordIndex = array_flip(preg_split('/\P{L}+/u', mb_strtolower($subject), -1, PREG_SPLIT_NO_EMPTY));
foreach ($terms as $term) {
if (isset($wordIndex[$term])) {
echo "match>".$term;
}
}