2012-07-25 88 views
0

我需要郵寄我的客戶,爲此我有一個csv文件,其中包含客戶數據,包括CSV文件中的電子郵件。如何使用PHP從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","[email protected]","Website Templates Pack","190830","xxxxxxxxxxx","1941602","PAYPAL","Once","xxxxxxxxxxxx","1","CHARGE","0","25","25","0","n/a","n/a"," "," "," "," "," "," "," ","xxxxx Account"," "," "," ","[email protected]" 

該文件包含超過3000條記錄(CSV文件)。我如何在PHP中查找/獲取所有電子郵件.. @ .. ..

謝謝

回答

2

只需遍歷CSV並抓取相應的字段即可。您使用fgetcsv()來執行此操作:

$emails = array(); 
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { 
    $emails[] = $data[5]; 
} 
相關問題