Jump to content

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

Any advantage to using \n compared to HTML - besides the quick syntax?

 

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.

Link to comment
https://forums.phpfreaks.com/topic/114030-solved-new-line/#findComment-586078
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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.