function clean(&$str) { if ($str === null) { return null; } $str = str_replace("\r\n", "\n", $str); $str = pg_escape_string($str); return $str; }