PHP在文件中写入Tab字符? [英] PHP to write Tab Characters inside a file?
问题描述
我如何简单地写出一个包含真正标签的文件? 标签
表示真实的标签
,这是而不是空格。如何编写标签
或真实标签的字符?
例如:
$ chunk =a,b,c
file_put_contents(chunk.csv,$ chunk);
我应该使用什么字符来获取标签
而不是 Commas(,)
有?
在输出文件中,应该有真实的 tabs
- Real Tabs意味着当我们按下
制表符字符为 \t
。请注意使用而不是
'
。
$ chunk =abc\tdef\tghi;
如果字符串包含在双引号()中,PHP会解释
更多转义序列字符:
...
\水平标签(HT或0x09(9)
此外,让我推荐 fputcsv()函数,用于写入CSV文件。
How do i simply write out a file including real tabs inside? tab
means real tab
which is not the spaces. How to write the tab
or what is the character for real tab
?
For example here:
$chunk = "a,b,c";
file_put_contents("chunk.csv",$chunk);
What character should i use to get tabs
instead of Commas (,)
there?
In the output file, there should be real tabs
between the seperated words.
- Real Tabs means, a true wide space we get when we press the
<tab>
key in a text-editor.
The tab character is \t
. Notice the use of "
instead of '
.
$chunk = "abc\tdef\tghi";
If the string is enclosed in double-quotes ("), PHP will interpret more escape sequences for special characters:
...
\t horizontal tab (HT or 0x09 (9) in ASCII)
Also, let me recommend the fputcsv() function which is for the purpose of writing CSV files.
这篇关于PHP在文件中写入Tab字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!