Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

from echo to file_put_contents

Posted on 2010-11-10
6
Medium Priority
?
442 Views
Last Modified: 2012-05-10
                 echo( implode(" ",$field )
                        . $CSV_separator);

echo to screen


I want to print to file.txt

file_put_contents("file.txt","----answer goes here---------------",FILE_APPEND);
0
Comment
Question by:rgb192
  • 3
  • 2
6 Comments
 
LVL 11

Expert Comment

by:Amar Bardoliwala
ID: 34101667
Hello rgb192,

I think you can do it as following..

file_put_contents("file.txt", implode(" ",$field ) . $CSV_separator, FILE_APPEND);

Thanks.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 34101718
Use the output control.
http://us.php.net/manual/en/ref.outcontrol.php

ob_start();
echo [whatever]
$string = ob_get_contents();
ob_end_clean();

file_put_contents(("file.txt", $string, FILE_APPEND);
0
 

Author Comment

by:rgb192
ID: 34104293
I have many echo statements

would this work


ob_start();
echo [whatever]

..
code
..

echo [whatever]



echo [whatever]

..
code
..

echo [whatever]



$string = ob_get_contents();
ob_end_clean();

file_put_contents(("file.txt", $string, FILE_APPEND);
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:rgb192
ID: 34104304
I have many echo statements   and for loops

would this work


ob_start();
echo [whatever]

..
code
..

for loop begin

echo [whatever]

for loop end

echo [whatever]

..
code
..

echo [whatever]



$string = ob_get_contents();
ob_end_clean();

file_put_contents(("file.txt", $string, FILE_APPEND);
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 34105410
Of course it will work.  The buffers are stackable.  Just put the ob_start() and ob_get... in the right places.
0
 

Author Closing Comment

by:rgb192
ID: 34110391
thanks
0

Featured Post

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.

Question has a verified solution.

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

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…
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 look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

972 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