Solved

Adding line breaks to code

Posted on 2008-09-30
1
184 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 500 total points
Comment Utility
You can use this:
for ($x = 0; $x < 5; $x++) {

  echo 'Line '.$x.'<br />'."\n";

}

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.

744 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now