You are here: Re: CSV into array « PHP Programming Language « IT news, forums, messages
Re: CSV into array

Posted by JDS on 10/12/05 21:38

On Wed, 12 Oct 2005 01:18:07 -0700, Tom wrote:

> I have a few products stored in a csv file created in Excel. Column 1
> is the part #, column 2 is title, column 3 is color, column 4 is width
> and 5 is price.

example of how I woud do it: (WARNING: Untested code!)

<?php
$file = file("theFile.csv");
$r=0;
foreach ($file as $line){
list($row[$r]['partno'], $row[$r]['title'], $row[$r]['color'],
$row[$r]['width'], $row[$r]['price']) = split(",", $line);
}
?>

That puts the whole file into a 2-dimensional arra ($row) that simulates
the layout of the Excel sheet. Do whatever you wnat with it after that.

--
JDS | jeffrey@example.invalid
| http://www.newtnotes.com
DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация