PHP按行读取文件 去掉换行符”\n”:

第一种:

$content=str_replace("\n","",$content);

echo $content;

或者:

$content=str_replace(array("\n","\r"),"",$content);

第二种:

$content=preg_replace("/\s/","",$content);
echo $content;

第三种:

$content=trim($content);

Leave a Reply

电子邮件地址不会被公开。 必填项已用*标注

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="">

请选择吧!