对写入csv表格的数据处理

public function processChar($str){
		//& / |
		//str_replace("\n", ", ", $values)
		$str = strip_tags($str);
		$str = str_replace("'","\'",$str);
		$str = str_replace('"','""',$str);
		$str =  str_replace(" "," ",$str);
		$str =  str_replace(" * ", " \* ",$str);
		$str =  str_replace("&"," ",$str);
		$str =  str_replace("/"," ",$str);
		$str =  str_replace("|"," ",$str);
		//$str =  preg_replace("'([rn])[s]+'", "", $str )
		$str=preg_replace("/\s/"," ",$str); 
		return $str;
	}

在csv中  "1"   是   ""1""  ,也就是说2个引号

去掉回车  preg_replace("/\s/"," ",$str);

你可能感兴趣的:(对写入csv表格的数据处理)