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. 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. 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))) 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 ! 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
Archived
This topic is now archived and is closed to further replies.