Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

LEGEND ,
Oct 24, 2008 Oct 24, 2008
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
==================


TOPICS
Server side applications
477
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 24, 2008 Oct 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 24, 2008 Oct 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 24, 2008 Oct 24, 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 25, 2008 Oct 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 25, 2008 Oct 25, 2008
LATEST
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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines