How to replicate this? "\n" is being used?
I am t开发者_如何学运维rying to replicate this using PHP:
2011-03-30;0;0;0;0\n2011-03-30;0;0;0;0\n2011-03-30;0;0;0;0\n2011-03-30;0;0;0;0\n2011-03-30;0;0;0;0\n2011-03-30;0;0;0;0\n2011-03-30;0;0;0;0
Although when I am doing so:
$hello = date("Y-m-d", $one) . ";0;0;0;0\n" . date("Y-m-d", $one) . ";0;0;0;0\n" . date("Y-m-d", $one) . ";0;0;0;0\n" . date("Y-m-d", $one) . ";0;0;0;0\n" . date("Y-m-d", $one) . ";0;0;0;0\n" . date("Y-m-d", $one) . ";0;0;0;0\n" . date("Y-m-d", $one) . ";0;0;0;0\n";
the "\n" is being used and placing the data on a new line each time, for example, it is being output as such:
2011-03-30;0;0;0;0
2011-03-30;0;0;0;0
2011-03-30;0;0;0;0
2011-03-30;0;0;0;0
2011-03-30;0;0;0;0
2011-03-30;0;0;0;0
2011-03-30;0;0;0;0
How can I stop this and replicate what I want?
Escape the backslash - so you have \\n
instead of \n
Using single quotes instead of double quotes. Single quotes are string literals so ignore special characters like \n
.
Either use single quotes (like Nick proposed) or escape the backslash by another backslash, so write:
";0;0;0;0\\n"
Single quotes OR escape the escape character \\n
Use single quotes. In this case you don't even need the double quote functionality.
http://es2.php.net/manual/en/language.types.string.php
精彩评论