Jump to content

[SOLVED] New Line


jj33

Recommended Posts

Guest Xanza

Use "\n" like unidox said...

 

 

Example Useage:

 

while($row = mysql_fetch_array($result)) {
    $out = $row["id"].',';
    $out .= $row["id_question"].',';
    $out .= $row["answer"].',';
    $out .= $row["position"].'\n';
    $out .= $row["status"].'\n';
}
    echo $out;

Link to comment
https://forums.phpfreaks.com/topic/114030-solved-new-line/#findComment-586062
Share on other sites

Just a correction.

 

while($row = mysql_fetch_array($result)) {
   $out = $row["id"].',';
   $out .= $row["id_question"].',';
   $out .= $row["answer"].',';
   $out .= $row["position"]."\n";
   $out .= $row["status"]."\n";
}
echo $out;

 

The newline \n char will not be interpolated within single quotes.

 

so i would have

$string = "paragraph \n second line";

 

to have

paragraph

second line

 

Yes, unless of course your wanting to output html newlines, in which case you still use the <br /> tag.

Link to comment
https://forums.phpfreaks.com/topic/114030-solved-new-line/#findComment-586067
Share on other sites

Guest Xanza

jj33, what he means is

 

$string = "This is line number one \n and this is line number two";

 

will output:

 

This is line number one

and this is line number two

 

Additionally, the same effect can be obtained by using <br>

 

$string = "This is line number one<br>and this is line number two";

 

which will output:

 

This is line number one

and this is line number two

 

A newline \n char only effects your html source code. It isn't at all relvent to html and what is output by a browser.

 

I'm in the habbit of using the \n newline simply because I do alot of shell scripting.

 

Ok! Sexy, thanks for the information!

Link to comment
https://forums.phpfreaks.com/topic/114030-solved-new-line/#findComment-586079
Share on other sites

Additionally, the same effect can be obtained by using

 

If you read my last post you will note \n and <br /> do not have the same effect at all. \n will not effect html, if you want a newline to appear in a browser you need to use htmls <br /> tag. \n will only effect the html source. ie; what you see when you rightclick->viewsource.

Link to comment
https://forums.phpfreaks.com/topic/114030-solved-new-line/#findComment-586081
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.