Skip to main content
Inspiring
October 24, 2008
Question

PHP: Can I print_r() an array into a text file?

  • October 24, 2008
  • 5 replies
  • 475 views
I have a serious array that I'd like to dump to a text file. Is there a
good way to do this short of recursing through the whole nasty mess?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


This topic has been closed for replies.

5 replies

Inspiring
October 25, 2008
On Sat, 25 Oct 2008 11:19:50 -0400, "Murray *ACE*"
<forums@HAHAgreat-web-sights.com> wrote:

>Yeah - worked fine, and taught me about a very useful concept: output
>buffering!
>
>Thanks, Gary.

You're welcome, Murray. Output buffering can be handy for stuff like
that.

Gary
Inspiring
October 25, 2008
Yeah - worked fine, and taught me about a very useful concept: output
buffering!

Thanks, Gary.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"Gary White" <reply@newsgroup.please> wrote in message
news:9l75g4tm95cn787lqb9ndogtjpc9bs8vcl@4ax.com...
> On Fri, 24 Oct 2008 17:02:03 -0400, "Murray *ACE*"
> <forums@HAHAgreat-web-sights.com> wrote:
>
>>Thanks - I'll check it out....
>
> Good luck!
>
> Gary

Inspiring
October 25, 2008
On Fri, 24 Oct 2008 17:02:03 -0400, "Murray *ACE*"
<forums@HAHAgreat-web-sights.com> wrote:

>Thanks - I'll check it out....

Good luck!

Gary
Inspiring
October 24, 2008
Thanks - I'll check it out....

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"Gary White" <reply@newsgroup.please> wrote in message
news:u9d4g41s5tlobupdi8709qvahk7e42i3go@4ax.com...
> On Fri, 24 Oct 2008 16:17:44 -0400, "Murray *ACE*"
> <forums@HAHAgreat-web-sights.com> wrote:
>
>>I have a serious array that I'd like to dump to a text file. Is there a
>>good way to do this short of recursing through the whole nasty mess?
>
> Untested, so don't yell at me if I miss an ending semicolon or
> something:
>
> ob_start();
> print_r($your_array);
> $var = ob_get_contents();
> ob_end_clean();
> $fp=fopen('some.file','w');
> fputs($fp,$var);
> fclose($fp);
>
> Gary

Inspiring
October 24, 2008
On Fri, 24 Oct 2008 16:17:44 -0400, "Murray *ACE*"
<forums@HAHAgreat-web-sights.com> wrote:

>I have a serious array that I'd like to dump to a text file. Is there a
>good way to do this short of recursing through the whole nasty mess?

Untested, so don't yell at me if I miss an ending semicolon or
something:

ob_start();
print_r($your_array);
$var = ob_get_contents();
ob_end_clean();
$fp=fopen('some.file','w');
fputs($fp,$var);
fclose($fp);

Gary