Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php explode new lines content from a txt file

I have txt file with email addresses under under the other like :

[email protected]
[email protected]

So far I managed to open it with

 $result = file_get_contents("tmp/emails.txt");
but I don't know to to get the email addresses in an array. Basically I could use explode but how do I delimit the new line ? thanks in advance for any answer !
like image 756
Michael Avatar asked Jul 18 '10 09:07

Michael


1 Answers

$lines = preg_split('/\r\n|\n|\r/', trim(file_get_contents('file.txt')));
like image 172
David Avatar answered Sep 21 '22 23:09

David