note 91195 added to function.fputcsv
| From: | soapergem at gmail dot com | Date: | Fri, 29 May 2009 15:09:46 +0000 |
| Subject: | note 91195 added to function.fputcsv | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-156148@lists.php.net to get a copy of this message | ||
In response to Sam's comment on tab delimiting: I'm sorry but you're mistaken. My own
tests just revealed that your second example works just fine. My best guess is that whatever text
editor you're using automatically replaces each horizontal tab with four spaces. You have to
ensure that it's really a tab character.
And the reason your first example didn't work is because you were using single quotes instead
of double. '\t' is interpreted literally as "backslash, lowercase-t,"--not as
the tab character. Remember that most of the escape sequences are only meant for double quotes (as
documented clearly in the manual entry on "strings"). So the following *three* examples
all work just fine:
<?php
fputcsv($fp, $foo, "\t");
fputcsv($fp, $foo, ' ');
fputcsv($fp, $foo, chr(9);
?>
Please note that the comment system here will probably replace the tab character in my second
example with four spaces, so un-replace it accordingly if you're going to copy/paste this. And
FYI: I tested this all on PHP 5.2.6.
----
Server IP: 64.71.164.2
Probable Submitter: 66.170.4.122
----
Manual Page -- http://www.php.net/manual/en/function.fputcsv.php
Edit -- https://master.php.net/note/edit/91195
Del: integrated -- https://master.php.net/note/delete/91195/integrated
Del: useless -- https://master.php.net/note/delete/91195/useless
Del: bad code -- https://master.php.net/note/delete/91195/bad+code
Del: spam -- https://master.php.net/note/delete/91195/spam
Del: non-english -- https://master.php.net/note/delete/91195/non-english
Del: in docs -- https://master.php.net/note/delete/91195/in+docs
Del: other reasons-- https://master.php.net/note/delete/91195
Reject -- https://master.php.net/note/reject/91195
Search -- https://master.php.net/manage/user-notes.php