DOMDocument encoding problems / characters transformed

前端 未结 4 1251
粉色の甜心
粉色の甜心 2020-12-16 23:56

I am using DOMDocument to manipulate / modify HTML before it gets output to the page. This is only a html fragment, not a complete page. My initial problem was that all fren

4条回答
  •  一整个雨季
    2020-12-17 00:53

    This was enough for me, the other answers here were overkill. Given I have an HTML document with an existing HEAD tag. HEAD tags don't have attributes and I had no issues leaving the extra META tag in the HTML for my use-case.

    $data = str_ireplace('', '', $data);
    $document = new DOMDocument();
    $document->loadHTML($data);
    

提交回复
热议问题