phdphd Posted December 7, 2012 Share Posted December 7, 2012 Hi All, I found a statement in a forum that enables to send an array via mail. mail($to, $subject, print_r($array, 1), $headers); The problem is that all the key/value pairs appear in a single line. I would like them to appear in seperate lines. (One solution could be adding a '<br />' at the end of each value, but I do not know how to do that with multidimensional arrays.) Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/271709-send-array-via-mail-with-each-value-in-separate-line/ Share on other sites More sharing options...
trq Posted December 7, 2012 Share Posted December 7, 2012 You will want to loop through your array and make a string from it. An array is a data structure, not something that can be simply emailed. Quote Link to comment https://forums.phpfreaks.com/topic/271709-send-array-via-mail-with-each-value-in-separate-line/#findComment-1398066 Share on other sites More sharing options...
Barand Posted December 7, 2012 Share Posted December 7, 2012 or, instead of just print_r($array, 1) , use nl2br(str_replace(" ",' ',print_r($array,1))) Quote Link to comment https://forums.phpfreaks.com/topic/271709-send-array-via-mail-with-each-value-in-separate-line/#findComment-1398089 Share on other sites More sharing options...
phdphd Posted December 7, 2012 Author Share Posted December 7, 2012 Thank you Barand, that is just perfect ! Quote Link to comment https://forums.phpfreaks.com/topic/271709-send-array-via-mail-with-each-value-in-separate-line/#findComment-1398093 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.