php – 解決 wordpress 的 \x08 問題
最近在接 wordpress 的文章,要顯示在 RSS,但遇到文字之間出現 “\x08” 造成 RSS 格式錯誤,可使用這種方式過濾掉 ASCII
1 2 3 4 5 6 7 8 9 10 11 12 |
/** * 移除 ascii 由 wordpress 產生的問題,造成 RSS 無法讀取 {@see https://xilou.info/p/121} * * @param $text * @return string|string[]|null */ public function removeAscii($text) { return preg_replace('/[\x00-\x08\x0b-\x0c\x0e-\x1f]/','', $text); } |