Edited at

制御文字を取り除く方法(改行コードは保持)

More than 5 years have passed since last update.

<?php

preg_replace('/[\x00-\x09\x0B\x0C\x0E-\x1F\x7F]/', '', $string); // The line feed and carriage return will be saved.

ここから拝借:

http://stackoverflow.com/questions/1497885/remove-control-characters-from-php-string