我需要邮寄我的客户,为此我有一个包含客户数据的csv文件,包括CSV文件中的电子邮件。
如何使用PHP读取所有电子邮件地址,将它们放入数组或将其插入文本文件(只是我可以使用的格式)
CSV如下所示:(样本记录)
"Date","Ref #","Time","Customer","Country","Email","Product","Product ID","Contract","Contract ID","Payment Type","Frequency","Referrer","Qty","Sale type","Adds","Total","Price","Plimus Commission","Affiliate Commssion (%)","Affiliate Commssion ($)","Tracking Id","CUSTOM1","CUSTOM2","CUSTOM3","CUSTOM4","CUSTOM5","Subscription ID","Target Balance","PayPal Comm.(main contracts)","PayPal Transaction ID","Original PayPal Transaction ID","PayPal email address"
"06/06/2008","19796287","04:06:29"," Mehmet Özekinci","Turkey","mhmtozek@gmail.com","Website Templates Pack","190830","xxxxxxxxxxx","1941602","PAYPAL","Once","xxxxxxxxxxxx","1","CHARGE","0","25","25","0","n/a","n/a"," "," "," "," "," "," "," ","xxxxx Account"," "," "," ","k_anafor56@hotmail.com"
该文件包含超过3000条记录(CSV文件)。如何在PHP中查找/获取所有电子邮件.. @ ..
谢谢
答案 0 :(得分:2)
只需循环访问CSV并抓取相应的字段即可。您可以使用fgetcsv()
执行此操作:
$emails = array();
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$emails[] = $data[5];
}