how to assign csv data into three different variables

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
prashantAG
Forum Newbie
Posts: 7
Joined: Wed Apr 30, 2008 1:31 am

how to assign csv data into three different variables

Post by prashantAG »

i have csv file contains username,firstname, and emails.
i want assign three variables from csv file seperately what i will do for that

this is code:
$fcontents = file('C:\Documents and Settings\winfo2\Desktop\user.csv');
# expects the csv file to be in the same dir as this script

for($i=1; $i<sizeof($fcontents); $i++) {
$line = trim($fcontents[$i]);

$arr = explode("\t", $line);

print_r( $arr);
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: how to assign csv data into three different variables

Post by Kieran Huggins »

Post Reply