Php 如何使用@hotmail.com提取所有字符串,

Php 如何使用@hotmail.com提取所有字符串,,php,Php,最后,如何使用@hotmail.com提取所有字符串。如果txt文件的名称为foo.txt a@a.com jhgvhdhf bahau@gmail.com hdghfd G@g.com dxf@hotmail.com sdfvdgfh ghb@hotmail.com 好吧,我今天没做好事: 祝你好运。从技术上讲,电子邮件地址可以包含空格,只要它们被引用。我相信hotmail不允许这样做,所以您应该能够使用以下功能: preg_match_all(/[^\s]+@hotmail\.com/,

最后,如何使用@hotmail.com提取所有字符串。如果txt文件的名称为foo.txt

a@a.com jhgvhdhf bahau@gmail.com hdghfd G@g.com dxf@hotmail.com
sdfvdgfh
ghb@hotmail.com

好吧,我今天没做好事:

祝你好运。从技术上讲,电子邮件地址可以包含空格,只要它们被引用。我相信hotmail不允许这样做,所以您应该能够使用以下功能:

preg_match_all(/[^\s]+@hotmail\.com/, $string, $matches);
//replace $string with file_get_contents('path/to/foo.txt')
在代码段上,
$matches
如下所示:

array ( 0 => array ( 0 => 'dxf@hotmail.com', 1 => 'ghb@hotmail.com', ), ) 排列( 0 => 排列( 0 => 'dxf@hotmail.com', 1 => 'ghb@hotmail.com', ), )
请尝试以下代码读取文件并进行分析:

if (($file = @file_get_contents('foo.txt'))
    && preg_match_all('/[^\s]+@hotmail.com/', $file, $matches)
) {
    $result = $matches[0];
}
所以$result将存储:

array(2) {
  [0]=>
  string(15) "dxf@hotmail.com"
  [1]=>
  string(15) "ghb@hotmail.com"
}

不要随意抑制错误或警告。他们来这里是有原因的回答像这样的问题只会鼓励帮助吸血鬼回答像这样的问题只会鼓励帮助吸血鬼。@GordonM:很公平。我没有意识到这实际上是OP问的前一个问题的重发。。。