我有一个文本文件,其中有一些空行。意思是线条上什么都没有,只是占用空间。
它看起来像这样:
The
quick
brown
fox jumped over
the
lazy dog
我需要它看起来像这样:
The
quick
brown
fox jumped over
the
lazy dog
如何删除这些空白行并仅获取包含内容的行并将它们写入新文件?
这是我知道该怎么做:
$file = fopen('newFile.txt', 'w');
$lines = fopen('tagged.txt');
foreach($lines as $line){
/* check contents of $line. If it is nothing or just a \n then ignore it.
else, then write it using fwrite($file, $line."\n");*/
}