Re: file delimited
| From: | Justin French | Date: | Mon, 24 Nov 2003 23:57:19 +0000 |
| Subject: | Re: file delimited | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-170834@lists.php.net to get a copy of this message | ||
On Sunday, November 23, 2003, at 10:50 PM, tony wrote:
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 '|'.You can do this with http://www.php.net/fgetcsv "array fgetcsv ( resource handle, int length [, string delimiter [, string enclosure]])" In this case, 'string delimiter' would be set to '|' rather than the default ','. There's some examples at the above URL.
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....This can all be achieved taking the above example and bending it to suit your needs. Justin French