Re: Parsing fgetcsv using tab (\t)
| From: | Jeff Harris | Date: | Tue, 01 Jul 2003 22:15:23 +0000 |
| Subject: | Re: Parsing fgetcsv using tab (\t) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-153623@lists.php.net to get a copy of this message | ||
On Jul 1, 2003, "Chris" claimed that:
|I'm trying to create an form where the user can upload a datafile to the
|server. The datafile will be txt or csv and contain multiple records. I
|would like the user to supply the field delimiter like (,) comma , (\t)
|tab or something else. The data records are then parsed using fgetcsv.
|
|The problem I'm having is trying to recover the tab character from the
|form post. If I print out what is received from my form I see the
|following \\t. I realize that the addition of the extra slash is
|expected, but what I don't know how to do is prepair this varable to use
|it in my fgetcsv argument.
|
|I've tried using stripslash but nothing seems to work for me.
|
|Strangely, if is set a variable in my processing script like:
|
|$field_terminater = "\t";
|
|Then supply this to: $newRecord = fgetcsv($f, $size,$field_terminater)
|everything works fine. If I use the variable passed from my form the
|records are not getting parsed.
|
|Any suggestions would be appreciated.
|Chris
|
[Not PHP]
Hard code the choices using radio buttons or a select on the form. There
shouldn't be too many commonly used delimiters, and those that use
uncommon delimiters will have to adjust.
[/Not PHP]
Then, use the value submitted to choose the delimiter in the php script.
Jeff
--
Registered Linux user #304026.
"lynx -source http://jharris.rallycentral.us/jharris.asc |
gpg --import"
Key fingerprint = 52FC 20BD 025A 8C13 5FC6 68C6 9CF9 46C2 B089 0FED
Responses to this message should conform to RFC 1855.