[thelist] Excel to PHP?
Gustavo Arizpe
listas at areaestrategica.com
Sat Sep 20 14:03:52 CDT 2003
> I have a 40 cell by 30 cell set of numbers in Excel and I want to put
> them into an array in PHP.
>
> How about it? Any one know how?
>
Hi,
There is a function for handling comma separated values in PHP,
fgetcsv().
First, save the Excel file as text, comma-separated, for example as
csvfile.txt.
Given that your file would have 30 rows:
$filename = csvfile.txt;
$fp = fopen ("$filename","r");
$data = fgetcsv ($fp, 30, ",") ;
Note that you can use any separator. For example if you decide to go
for tab-separated, the array declaration would be:
$data = fgetcsv ($fp, 30, "\t");
Hope this helps.
Gustavo Arizpe
http://marketing.typepad.com
More information about the thelist
mailing list