<?php
function clean($string) {
    eval("\$string = \"$string\";");
   $string = str_replace(' ', ' ', $string); // Replaces all spaces with hyphens.
   return preg_replace('/[^a-zA-Z0-9_ %\[\]\.\(\)%\\:@&-]/s', '', $string); // Removes special chars.
}

$d =  clean("this was http:\\nice readlly n'ice 'test for@me to") ;
echo $d;
?>