2013-05-21 30 views
-1

我有两个文件文件获取,并把内容以文本文件与新的生产线

File1.php和File2.php

$hello = file_get_contents("file1.php"); 
file_put_contents("hello.txt",$hello); 

file1.php包含像一些例如文本下面

hello \r\n hi \r\n how are you. 

我需要的是当我把内容放到hello.txt中时,我想让这些文字出现在下面的新行中

hello 
hi 
how are you. 

我试图用\ r \ n和\ n但没有任何工程

注: file1.php是另一页source..i的的file_get_contents只能\r\n取代<br>标签,这仅仅是一个例。我还有其他复杂的部分要做。

+0

我认为你需要做这样的事情'file_put_contents( “hello.txt的”,$你好)。 “\ n”;' –

+0

当你替换时,你是否确保使用双引号'''而不是单引号''''$ string =“Hello \ r \ nWorld”;''会是'Hello [ NEWLINE] World''''string ='Hello \ r \ nWorld';'将会是'Hello \ r \ nWorld'(文字字符); – h2ooooooo

+0

nope .. $ hello包含多个分隔线..如何工作 – Vishnu

回答

1

我觉得你应该把东西在每行的末尾,

,那么你可以取代它白衣:

str_replace 

功能,我认为这会工作

str_replace('[EndOfLine]', "\r\n", $string); 
-1

让您File1.php包含本文

hello 
hi 
how are you. 

和您的代码将很好地工作!

+0

的一个,它禁止其他页面源的file_get_contents ..我只能用\ r \ n替换
标记 – Vishnu