note 91195 deleted from function.fputcsv by danbrown
| From: | danbrown@php.net | Date: | Fri, 29 May 2009 17:21:03 +0000 |
| Subject: | note 91195 deleted from function.fputcsv by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-156161@lists.php.net to get a copy of this message | ||
Note Submitter: soapergem at gmail dot com
----
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.