Tuesday 15 February 2011

text - Adding line breaks to a bare string (PHP) -


If I dynamically download a text file from my website that contains information from the database, I will:

  $ name = $ _GET ["Download"]; $ File = get_file_data ($ name); If ($ file) {header ("content-dispute: attachment; filename =". $ [["Custom_name"]] ".txt"); Header ("content-type: text / plain"); Copy $ file ["stuff"]; Go out(); }  

Where $ file ["stuff"] is a bare string of text read directly from the database

However, the archived text There is no clear line breaks in it, instead of when they show unbridled, the paragraph blocks look like a big space between the blocks.

(For example, when they are displayed

for example

example

>

  Final Question by Isaac Asimov & Copy; 1956 The last question was asked for the first time, for the first half, on 21 May, 2061, there was a time when humanity first came to light. As a result of the dollar condition came, and it happened like this:  

How can I loop on any string like this and PHP_EOL End of each line?

Add a \ n string But make sure it is added to double quotes. Example:

  "line 1 \ n line 2" echo  

No comments:

Post a Comment