Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Adding line breaks to code

Posted on 2008-09-30
1
Medium Priority
?
200 Views
Last Modified: 2012-05-05
I'm having trouble producing code that can be easily read by humans in a browsers 'view source'

The code below looks like this in view source;

Line 0<br />Line 1<br />Line 2<br />Line 3<br />Line 4<br />

However I would like view source to look like this (without changing the rendered version of the page);
Line 0<br />
Line 1<br />
Line 2<br />
Line 3<br />
Line 4<br />

Can this be done?
for ($x = 0; $x < 5; $x++) {
  echo 'Line '.$x.'<br />';
}

Open in new window

0
Comment
Question by:Mr_Splash
1 Comment
 
LVL 48

Accepted Solution

by:
hernst42 earned 2000 total points
ID: 22604601
You can use this:
for ($x = 0; $x < 5; $x++) {
  echo 'Line '.$x.'<br />'."\n";
}

Open in new window

0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question