开发者

PHP parse csv list and insert each record into wordpress users database

开发者 https://www.devze.com 2022-12-21 01:38 出处:网络
I\'ve got an excel file containing a list of records by firstname, lastname, email_address, transaction_id

I've got an excel file containing a list of records by firstname, lastname, email_address, transaction_id

I'd like to create a script that reads in the excel data (can be csv or whatever export is easiest to work with) and inserts each record as a user in my wordpress database with the role of "membe开发者_StackOverflowr".


You can explode each line on the delimter (like ,) or you could use fopen and fgetcsv to parse line by line. Overall the general procedure is not difficult. for example:

$fileResource = fopen('/path/to/file.csv', 'r');
while(($data = fgetcsv($fileResource, ',')) !== false)
{
   // $data is numeric indexed array
   // do stuff with $data
}
0

精彩评论

暂无评论...
验证码 换一张
取 消