一些PHP ereg_replace問題。我有名字的數組:PHP ereg_replace問題
$ssKeywords = array("Str", "Int", "String", "As", "Integer", "Variant");
然而,當我使用這個ereg_replace:
foreach($arKeyword as $aWord) {
$sCode = ereg_replace($aWord, "<span class='ssKeyword'>".$aWord."</span>", $sCode);
}
它只會找到「STR」或「INT」不是完整的比賽。顯然ereg_replace是貪婪的,爲什麼它不尋找完整的匹配?
我設法使用preg_replace來獲取註釋。
使用此功能只會導致錯誤。 –
存在的錯誤的意義是固定的,不要被使用不同的功能遺忘;) – bezmax
嗯,我的評論工作!現在只是關鍵字。 –