Solved

HOw to continue new data in new line

Posted on 2008-06-11
7
714 Views
Last Modified: 2008-06-15
PHP
i have this data in my text file

a|b|c|d|e|f
suppose d|e|f should be in new line

i use file_put_contents('c:\\'.$fn.'.txt',$data1 , FILE_APPEND);
can i use "\r\n" here?
0
Comment
Question by:firekiller15
  • 3
  • 2
  • 2
7 Comments
 
LVL 4

Accepted Solution

by:
afzz earned 250 total points
ID: 21766592

$data1="a|b|c|"."\r\n"."d|e|f;

file_put_contents('c:\\'.$fn.'.txt',$data1 , FILE_APPEND);

Open in new window

0
 
LVL 4

Assisted Solution

by:afzz
afzz earned 250 total points
ID: 21766598
sorry, missed the "
$data1="a|b|c|"."\r\n"."d|e|f";

file_put_contents('c:\\'.$fn.'.txt',$data1 , FILE_APPEND);

Open in new window

0
 
LVL 29

Expert Comment

by:fibo
ID: 21766765
Depnding on which computer is file is saved on / displayed on, the "newline" might differ.
Your script hints that you are running on windows, therefore \r\n should work.

$newline ='\r\n'; // change if Unix
$data1="a|b|c|".$newline."d|e|f";
file_put_contents('c:\\'.$fn.'.txt',$data1 , FILE_APPEND);
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:firekiller15
ID: 21766963
how about if abc is variable as follow

 $data1="$a|$b|$c|"

can i still use "\r\n" ?
0
 
LVL 29

Expert Comment

by:fibo
ID: 21767172
I would guess so
$newline ='\r\n'; // change if Unix
$data1="$a|$b|$c|$newline$d|$e|$f";
$debug=true; // easy to change
if ($debug) { echo "** string is[$data1] **";}; // html should display on several lines
file_put_contents('c:\\'.$fn.'.txt',$data1 , FILE_APPEND);
0
 

Author Comment

by:firekiller15
ID: 21775153
no what i mean is example
a|b|c has this value
1|2|3
4|5|6
7|8|9
instead of output the value 123|456|789
how can i output it with newline as shown below
1|2|3
4|5|6
7|8|9
0
 
LVL 29

Expert Comment

by:fibo
ID: 21777019
Not sure I understand clearly.
What is the value of $a?
The value of $b?
Can you paste the lines of code which generate $a? same for $b and $c
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

760 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

22 Experts available now in Live!

Get 1:1 Help Now