Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

from echo to file_put_contents

Posted on 2010-11-10
6
Medium Priority
?
439 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
[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
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Technology Partners: 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!

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

715 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