Solved

HOw to continue new data in new line

Posted on 2008-06-11
7
715 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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 create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

910 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

16 Experts available now in Live!

Get 1:1 Help Now