i have this in php :
echo '"dayCaption":"'.$colNumberOfWeek.' '.$numberOfWeek.'",';
But i want to complete this . I want to skip a line and add another variable [ $xxx for exemple ]
in parentheses...
Thanks
asked Feb 23, 2017 at 8:56
9
You may try this
echo '"dayCaption":"'.$colNumberOfWeek.' '.$numberOfWeek.'", ';
echo " ";
echo "[";
echo $xxxx;
echo "]";
answered Feb 23, 2017 at 9:02
6
i think u want to put in a Enter. so after your last value on line 1 put in +"/r/n" [not sure if it has to be in quotes]
echo $value1 . $value2 . "/r/n" . $value3
echo '"dayCaption":"'.$colNumberOfWeek.' '.$numberOfWeek.' './r/n.' '.$value3.'",';
answered Feb 23, 2017 at 9:01
B. DionysB. Dionys
8847 silver badges33 bronze badges
7
I have updated your code, please try this code:
echo "dayCaption: ".$colNumberOfWeek." ".$numberOfWeek."
[".$xxx."]";
Or
echo "dayCaption: ".$colNumberOfWeek." ".$numberOfWeek;
echo "
";
echo "[".$xxx."]";
Both will display the same results.
I hope, this will be helpful to you.
answered Feb 23, 2017 at 9:08
Prateek VermaPrateek Verma
8591 gold badge6 silver badges9 bronze badges
❮ PHP String Reference
Example
Insert line breaks where newlines [\n] occur in the string:
The browser output of the code above will be:
One line.
Another line.
The HTML output of the code above will be [View Source]:
One line.
Another
line.
Try it Yourself »
Definition and Usage
The nl2br[] function inserts HTML line breaks [
or
] in front of each newline [\n] in a string.
Syntax
Parameter Values
string | Required. Specifies the string to check |
xhtml | Optional. A boolean value that indicates whether or not to use XHTML compatible line breaks:
|
Technical Details
Returns the converted string |
4+ |
The xhtml parameter was added in PHP 5.3. Before PHP 4.0.5, it inserted . After PHP 4.0.5 it inserts . |
More Examples
Example
Insert line breaks where newlines [\n] occur, using the xhtml parameter:
The browser output of the code above will be:
One line.
Another line.
The HTML output of the code above will be [View Source]:
One line.
Another line.
Try it Yourself »
❮ PHP String Reference
🏠 » Q&A » How To Echo A Line Break / New Line In PHP
Answer: In PHP to echo a new line or line break use ‘\r\n’ or ‘\n’ or PHP_EOL
If HTML uses
to create a line break, in PHP you can create a new line using 3 different methods :
1. PHP new line character ‘\n’ or ‘\r\n’
‘\n’ or ‘\r\n’ is the easiest way to embed newlines in a PHP string. Also, ‘\n’ can be used to create line breaks when creating PHP text files.
See the following example:
echo"Seegatesite.com\r\nThe best programming blog"; |
Result :
What is the difference ‘\n’ or ‘\r\n’ ?
\n Used to write a new line on a UNIX system, while Windows reads a new line with the \r\n character.
2.PHP_EOL: PHP Core Predefined Constants
PHP_EOL is predefined constants to translate the end of a line in PHP. Source : PHP Manual
Example:
echo"Create Line Break PHP".PHP_EOL."With PHP_EOL"; |
Result :
3. Using nl2br[]
Used to add HTML line breaks in a string [the HTML code we usually use to create new lines
]
Example :
echo nl2br["Seegatesite.com \nsharing and learning programming"]; |
Result :
Conclusion :
The three methods above used according to your needs in creating new lines in PHP.
This site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.