我有 csv 文件mail.csv
,我有如下文本:
d,2012-08-24 00:00:57+0200,2012-08-24 00:00:45+0200,noreply@news.camera-factice.com,...
d,2012-08-24 00:00:57+0200,2012-08-24 00:00:45+0200,noreply@118-bonsplans.com,toulouse@texa.fr,...
b,2012-08-24 00:00:57+0200,2012-08-22 23:59:31+0200,noreply@lemeilleur-duweb.com,...
b,2012-08-24 00:00:57+0200,2012-08-22 23:59:31+0200,noreply@lemeilleur-duweb.com,...
我只想获取 mail.exaple: noreply@lemeilleur-duweb.com
。如果邮件有 2 个或更多邮件相同,我只想接收一封邮件。我的代码 php 如下:
<?php
$handle = fopen('acct-2012-08-24-0001.csv', 'r');
$mail = 'noreply@118-bonsplans.com';
$respon = 'fail';
$Totalcounter = 0;
$mailFail = 0;
$percentage = 0;
$data[]="";
if ($handle) {
while (($buffer = fgets($handle, 4096)) !== false) {
if (stristr($buffer, '118-bonsplans.com')) $Totalcounter += 1;
if(($data = fgetcsv($handle, 1000, ",")) !== FALSE);
if (stristr($buffer, $mail) && stristr($buffer,$respon)) $mailFail += 1;
} fclose($handle);
//echo $data[3];
}
$percentage = ($mailFail/$Totalcounter)*100;
echo '<table border="1px">';
echo "<tr><td>Dormain</td><td>Total</td><td>Mail Fail</td><td>Percentage</td></tr>";
echo "<tr><td>".$data[3]."</td><td>".$Totalcounter."</td><td>".$mailFail."</td><td>".$percentage."</td></tr>";
echo '</table>';
?>
注意
对于此代码,我编写它是if(($data = fgetcsv($handle, 1000, ",")) !== FALSE);
为了从 csv 文件中获取邮件。但它不起作用。
请任何人帮助我,谢谢