需要幫助。我無法替換'&'和'&',它們在PHP中使用Preg_replace。但是,如果我在xml文件上手動(編輯)它,它工作得很好。XML中無法替換&&使用PHP中的Preg_replace
下面是該示例:
$XMLCharactersPreg = "/[&<>\"\'()^*@+]/";
$XMLPregReplace = "&";
$d_Description = "50% offer & 20% further reduction for member";
if (preg_match($XMLCharactersPreg, $d_Description)) {
echo "A match was found.";
$XMLDealDescription = preg_replace($XMLCharactersPreg , $XMLPregReplace, $d_Description);
echo "$XMLDealDescription <br/>";
} else {
echo "A match was not found.";
}
感謝。
你的代碼適合我。 – 2010-06-17 07:03:34
你看過htmlentities()嗎? – Sjoerd 2010-06-17 07:06:10