Parsing fgetcsv using tab (\t)
| From: | Chris | Date: | Tue, 01 Jul 2003 22:50:15 +0000 |
| Subject: | Parsing fgetcsv using tab (\t) | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-153610@lists.php.net to get a copy of this message | ||
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