?
Solved

HOw to continue new data in new line

Posted on 2008-06-11
7
Medium Priority
?
722 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 4

Accepted Solution

by:
afzz earned 750 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 750 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

777 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