Solved

HOw to continue new data in new line

Posted on 2008-06-11
7
718 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 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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…
The viewer will learn how to dynamically set the form action using jQuery.

738 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