How can I remove the NULL character from string

前端 未结 3 1102
孤街浪徒
孤街浪徒 2020-12-28 17:23

I have a PHP variable that contains a string which represents an XML structure. This string contains ilegal characters that dont let me build a new SimpleXMLElement object f

3条回答
  •  旧巷少年郎
    2020-12-28 18:09

    $text = str_replace("\0", "", $text);
    

    will replace all null characters in the $text string. You can also supply arrays for the first two arguments, if you want to do multiple replacements.

提交回复
热议问题