我试过这个PHP代码从eml文件中提取电子邮件地址。但它表明我的浏览器是这样的:我怎样才能提取电子邮件地址从一个Excel文件从eml文件使用php
Array ([0] => [email protected]
[1] => [email protected]
[8] => [email protected]
[16] => [email protected]
[23] => [email protected]
[26] => [email protected]
[33] => [email protected]
[35] => [email protected] [64] => [email protected]
[67] => [email protected] [68] => [email protected]
[87] => [email protected]
[94] => [email protected]
[97] => [email protected]
[104] => [email protected]
)`
我的PHP代码:
<?php
$emails = array();
foreach(rglob("*.eml") as $eml){
$emlContent = file_get_contents($eml);
preg_match_all('/([A-Z0-9._%+-][email protected][A-Z0-9.-]+\.[A-Z]{2,6})/i', $emlContent, $matches, PREG_PATTERN_ORDER);
for ($i = 0; $i < count($matches[1]); $i++) {
$emails[] .= $matches[1][$i];
}
}
$emails = array_unique($emails);
print_r($emails);
function rglob($pattern='*', $flags = 0, $path=''){
$paths=glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT);
$files=glob($path.$pattern, $flags);
foreach ($paths as $path) {
$files=array_merge($files,rglob($pattern, $flags, $path));
}
return $files;
}
?>
现在我想只提取所有发件人的电子邮件地址到Excel文件。我在互联网上搜索,但没有得到任何解决方案。
希望有人能帮助我解决问题。提前 感谢
是的,它开始下载。但我只需要将电子邮件地址插入到xls文件中。只需要提取电子邮件。 @kisaragi – sohag513
只需在'foreach'循环中回显值。 – Kisaragi
它正在工作......谢谢你 – sohag513