English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I am new to PHP and MySQL...I want to store data in a text file with a PHP script running on my server.For Client-side I have used a Flash interface....I want to know how can I insert line breaks in the data that is saved in the text file.By default all the data appears as one single line which is quite difficult to understand...

2007-02-12 01:12:13 · 5 answers · asked by Anonymous in Computers & Internet Programming & Design

5 answers

Try something like this:
$newdata = preg_replace('/(.{1,75}\s)/ ', '\1\n', $data;
This goes through $data, finds strings of 1 to 75 characters plus a whitespace character, replaces that with the found string plus a line break and puts the result in $newdata. If you use something other than spaces as a delimiter, replace \s with whatever you use.

2007-02-12 04:51:07 · answer #1 · answered by injanier 7 · 0 0

unsure relating to the pipes. besides the undeniable fact that possibly in case you probably did a replace and adjusted the |'s with , 's this way you're able to be waiting to insert the archives with some style of CSV (comma separated vales ) to sq. script. or possibly get Hypertext Preprocessor to envision a line, enter the archives between the |'s to a gaggle of strings $a $b $c and so on. then to a INSERT into Blaaa values $a,$b,$c ? and repeat until the top of report. those style of questions would be maximum suitable spoke back on a committed Hypertext Preprocessor communicate board. a minimum of there you will locate greater Hypertext Preprocessor programmers.

2016-11-03 05:46:33 · answer #2 · answered by ? 4 · 0 0

If you are using php to output the information, perhaps the simplest approach is the nl2br function. This function converts the "hidden" new line characters in your text file into their html equalvalent "
";

2007-02-12 05:10:13 · answer #3 · answered by Anonymous · 0 0

Use the \n escape character.

I also believe these work:

\t - tab
\r - Return

These only work when the information is collected using double quotes ( " ). Single quotes will output the \n exactly as it looks

If that does work, try /n, I may have the slash backwards

2007-02-12 01:17:31 · answer #4 · answered by Clinton G 2 · 0 0

Insert
"\r\n"
where you want a line break & it will work as you want.

2007-02-12 22:54:25 · answer #5 · answered by Atif Majid 3 · 0 0

fedest.com, questions and answers