Re: file delimited

From: Date: Mon, 24 Nov 2003 14:34:29 +0000
Subject: Re: file delimited
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-170792@lists.php.net to get a copy of this message
array fgetcsv ( resource handle, int length [, string delimiter [, string enclosure]]) PHP manual extract: <?php $row = 1; $handle = fopen ("test.csv","r"); while ($data = fgetcsv ($handle, 1000, ",")) { $num = count ($data); print "<p> $num fields in line $row: <br>\n"; $row++; for ($c=0; $c < $num; $c++) { print $data[$c] . "<br>\n"; } } fclose ($handle); ?>Lucian"Tony" <awardd@essex.ac.uk> wrote in message news:20031123115031.39515.qmail@pb1.pair.com... > Hi, > > I'm new to php I just come from perl, and I wanted to know like perl if we > can open a file and read delimited line just like the cvs function, but I > don't want comma separated, i want the vertical bar '|'. > also if we read that file can the 'column' go in an array like perl > i.e if we have a record > Name|Phone|address|age|email > can we put it into an array like > $record[] > and say > $record[0] is Name, $record[1] is Phone etc.... > > Any help is well appreciated.

« previous php.general (#170792) next »