Friday, October 7, 2011

Cleaning the unwanted Characters in a String

function cleanStringData(&$str) {
  $str = preg_replace("/\t/", " ", $str);
  $str = preg_replace("/\r?\n/", " ", $str);
  $str = preg_replace("/,/", "|", $str);
}

$string = "this, is a valid string";
cleanStringData($string);
echo "--".$string;

No comments:

Post a Comment

Followers