In php, how do I load txt file as a string?

后端 未结 4 1525
被撕碎了的回忆
被撕碎了的回忆 2021-01-02 19:01

I have a text file that contains paragraphs of text. I want to load it as a string in php, and then collect all the e-mail addresses within it as an array. However, how do

相关标签:
4条回答
  • 2021-01-02 19:15

    file_get_contents

    0 讨论(0)
  • 2021-01-02 19:22
    $lines = file('file.txt');
    
    foreach ($lines as $line) {
      // ...
    }
    0 讨论(0)
  • 2021-01-02 19:23
    $fileContent = file_get_contents($url);
    

    Check the reference at http://php.net/manual/en/function.file-get-contents.php

    0 讨论(0)
  • 2021-01-02 19:23

    The simplest way is file-get-contents!

    $file_content = file_get_contents('/path/to/file');
    
    0 讨论(0)
提交回复
热议问题