Source Code:
(back to article)
<?php $string = "This is a \r\nstring with\tnon-printable\x0Bcharacters."; $string = preg_replace('/[\x00-\x1F\x80-\xFF]/', ' ', $string); $string = preg_replace('/\s+/', ' ', $string); // add this line to replace multiple spaces with a single space echo $string; // Outputs: "This is a string with non-printable characters."
Result:
Report an issue