Hi All,
Newline(\n) is not inserting a new line on the browser. Can some body help me how can I insert a new line on the browser.

I know the html tag<br /> will help. But is there any other way ?

Here is the snippet of the code which i used

<body>       <?php
            echo "\n\n Continue and  For Loop  \n ";

            for($count=0; $count <= 10; $count++)
        if($count == 5)
        echo "value of \$count is ::> $count \n   " ;



Recommended Answers

A newline only works within a <pre> tag.

Jump to Post

All 2 Replies

\n is not a html tag. It does insert a new line in the source (view page source and you will see it). To have a new line in html page you need to use either <br /> or wrap each line in <p></p> or <div></div> pair like

echo "<div>value of \$count is ::> $count </div>" ;

You can change the spacing between lines with css.

The other option is to use nl2br() function. See http://php.net/manual/en/function.nl2br.php.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.