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!

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.