Jump to content

Store contents of an array export into a new variable


purefusion

Recommended Posts

Hi. I'm looking to store the string printed by either var_dump(), var_export() or printr() into a new non-array variable for quick sending of email. Any ideas?

Also, is there such a thing as a "Pretty" Variable Dump? Maybe a loop that would store the array in a pretty string format?

It's not important enough that it needs to be formatted to look nice, but there is a lot of information coming from the form.

Thanks so much!

Link to comment
Share on other sites

The [a href=\"http://www.php.net/var_export\" target=\"_blank\"]var_export()[/a] and [a href=\"http://www.php.net/print_r\" target=\"_blank\"]print_r()[/a] function will both send their output to a variable if the second parameter is "true".

So to send in email, you can do
[code]<?php $body = print_r($_POST,true); ?>[/code]
If you just want to display it on the screen, do [code]<?php echo '<pre>' . print_r($_POST,true) . '</pre>'; ?>[/code]

Ken
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.