Remove whitespace from HTML

前端 未结 15 1788
花落未央
花落未央 2020-12-28 14:25

I have HTML code like:

15条回答
  •  温柔的废话
    2020-12-28 14:48

    if you got 8 bit ASCII, is will remove them and keep the chars in range 128-255

     $text = preg_replace('/[\x00-\x1F\xFF]/', " ", $text );
    

    If you have a UTF-8 encoded string is will do the work

    $text = preg_replace('/[\x00-\x1F\x7F]/u', '', $text);
    

    for more information you have this link more information

提交回复
热议问题