Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

HOw to continue new data in new line

Posted on 2008-06-11
7
Medium Priority
?
723 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
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

609 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