PHP to write Tab Characters inside a file?

安稳与你 提交于 2019-11-30 03:07:48

The tab character is \t. Notice the use of " instead of '.

$chunk = "abc\tdef\tghi";

PHP Strings - Double quoted

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.

Use \t and enclose the string with double-quotes:

$chunk = "abc\tdef\tghi";

This should do:

$chunk = "abc\tdef\tghi";

Here is a link to an article with more extensive examples.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!