Я пробовал этот код PHP для извлечения адресов электронной почты из файла eml. но он показывает мне в браузере вот так:
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._%+-]+@[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. Я искал в Интернете, но не нашел решения.
Надеюсь, кто-нибудь поможет мне решить проблему. заранее спасибо