[英]PHP simple html dom damaging indentation
我正在使用PHP簡單html dom編輯一些html文件。 問題是,當我保存時,它將刪除所有回車符。 我該如何保存它們? 謝謝
API文檔沒有顯示它們,但是file_get_html
和str_get_html
函數有很多有趣的參數,只需打開simple_html_dom.php
:
function file_get_html(
$url, $use_include_path = false, $context=null, $offset = -1,
$maxLen=-1,
$lowercase = true,
$forceTagsClosed=true,
$target_charset = DEFAULT_TARGET_CHARSET,
$stripRN=true,
$defaultBRText=DEFAULT_BR_TEXT)
function str_get_html(
$str,
$lowercase=true,
$forceTagsClosed=true,
$target_charset = DEFAULT_TARGET_CHARSET,
$stripRN=true,
$defaultBRText=DEFAULT_BR_TEXT)
也許您可以將$stripRN
設置$stripRN
false,否則可以在simple_html_dom->prepare()
:
//before we save the string as the doc... strip out the \r \n's if we are told to.
if ($stripRN) {
$str = str_replace("\r", " ", $str);
$str = str_replace("\n", " ", $str);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.