mattspriggs28 Posted July 20, 2010 Share Posted July 20, 2010 Hi, I'm wanting to debug a couple of errors on a live site. I have a form that is filled in and the data is stored in an array, as well as the validation error messages before anything is submitted to the database. What I'm wanting to do is fire the array data in an email to myself so I can see what has been submitted in the form in order to see where a particular error may be occuring. I understand that to output the values of an array you need to use print_r(), but how do I add this output to a variable in order to slot it in the body of an email? Thanks for your help. Link to comment https://forums.phpfreaks.com/topic/208273-error-debugging/ Share on other sites More sharing options...
TheEvilMonkeyMan Posted July 20, 2010 Share Posted July 20, 2010 print_r() has a second parameter called 'return' and it's a true/false of whether it will print the output or return it. Here's an example taken from the PHP manual page for print_r() <?php $b = array ('m' => 'monkey', 'foo' => 'bar', 'x' => array ('x', 'y', 'z')); $results = print_r($b, true); // $results now contains output from print_r ?> Link to comment https://forums.phpfreaks.com/topic/208273-error-debugging/#findComment-1088531 Share on other sites More sharing options...
mattspriggs28 Posted July 20, 2010 Author Share Posted July 20, 2010 Thanks, that's just what I needed! Link to comment https://forums.phpfreaks.com/topic/208273-error-debugging/#findComment-1088542 Share on other sites More sharing options...
TheEvilMonkeyMan Posted July 20, 2010 Share Posted July 20, 2010 you're welcome Link to comment https://forums.phpfreaks.com/topic/208273-error-debugging/#findComment-1088544 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.