在php中,如何将txt文件加载为字符串? [英] In php, how do I load txt file as a string?
本文介绍了在php中,如何将txt文件加载为字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含文本段落的文本文件.我想将其作为字符串加载到php中,然后将其内的所有电子邮件地址收集为一个数组.但是,最初如何将文本文件内容作为字符串加载?重述,我有
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 I initially load the text file contents as the string? Restated, I have
$string = **WITHIN TEXT FILE "user@domain.com MIME-Version: bla bla bla user2@example.com";
$matches = array();
$pattern = '/[A-Za-z0-9_-]+@[A-Za-z0-9_-]+\.([A-Za-z0-9_-][A-Za-z0-9_]+)/'
preg_match($pattern, $string, $matches);
如何将文本文件中的文本加载到字符串变量中?
How do I load the text from the text file into the string variable?
提前谢谢!
推荐答案
$fileContent = file_get_contents($url);
在 http://php.net/manual/zh/function.file-get-contents.php
这篇关于在php中,如何将txt文件加载为字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文