php 如何从txt读出每行并去除换行符

2025-01-01 01:08:26
推荐回答(1个)
回答1:

第一种:
$content=str_replace("\n","",$content);
echo $content;
或者:
$content=str_replace(array("\n","\r"),"",$content);
第二种:
$content=preg_replace("/\s/","",$content);
echo $content;