How do I simply write out a file containing real tabs? tab
represents the real tab
, which is not a space. How to write tab
or what characters are the real tab
?
For example here:
$chunk = "a,b,c"; file_put_contents("chunk.csv",$chunk);
What characters should I use to get tabs
instead of comma (,)
there?
In the output file, there should be real tabs
between delimited words.
key in a text editor, we get a real wide space.
Use
\t
and enclose the string with double-quotes:The tab character is
\t
. Notice the use of"
instead of'
.PHP String - Double Reference
Also, let me recommend the fputcsv() function, which is used to write CSV files.