Re: fgetcsv() delimiters ?

From: Date: Wed, 09 Apr 2003 07:46:09 +0000
Subject: Re: fgetcsv() delimiters ?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-143021@lists.php.net to get a copy of this message
Howdy, and thanks for the reply, Ill look into using the functions you suggest, being new to PHP Ill do the neccessary research and if need be post again on this topic. Thanks for the help. Chris On Tue, 2003-04-08 at 16:55, Burhan Khalid wrote: > On Tue, 2003-04-08 at 08:03, Chris Blake wrote: > > Greetings learned PHP(eople) > > > > The following code opens a text file and puts all the lines in the file > > into an array, so that I can take each line and compile a nice table > > with the order info in it. > > > [ snip ] > > > The problem is, I`m using the tab delimiter with fgetcsv(), but some of > > the entries in the file were not entered using this format. Looking at > > the text file content in vim it appears that a single space is used, or > > some other delimiter. > > > > Do I need to loop through the file again using fgetcsv(), this time > > using another delimiter value ? > > That sounds like a round-about way of doing it. > If all you want is a list of values in an array, you can use the file() > function, which does exactly that : > > $contents = file($filename); > while(list($number,$line) = each($contents)) { > echo "Line Number : ".$number." Contents : ".$line. "<br > />"; > } > > Then, you can use the explode function to lob each "delimited" part off > with whatever delimiter you have. Seems to me calling fgetcsv() would > lead to unnecessary overhead. > > My $0.02 > > -- > Burhan Khalid > phplist[at]meidomus[dot]com > > Please add a reply-to: header with the > address of the list so replies will > be relayed back to the list. > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- Chris Blake Office : (011) 782-0840 Cell : 083 985 0379 Linux vs. Windows is a no WIN situation.

« previous php.general (#143021) next »