tomasd Posted April 8, 2008 Share Posted April 8, 2008 Hi, I was using php's mail function and on the manual it says that message must be string, I have an array consisting of objects I want to mail; stdClass Object ( [check_date] => 2008-04-08 00:17:53 [out_date] => 2008-06-07 [price] => 24.99 ) stdClass Object ( [check_date] => 2008-04-08 00:17:53 [out_date] => 2008-06-07 [price] => 24.99 ) stdClass Object ( [check_date] => 2008-04-08 00:18:02 [out_date] => 2008-06-14 [price] => 24.99 ) stdClass Object ( [check_date] => 2008-04-08 00:18:02 [out_date] => 2008-06-14 [price] => 24.99 ) stdClass Object ( [check_date] => 2008-04-08 00:18:08 [out_date] => 2008-06-21 [price] => 34.99 ) stdClass Object ( [check_date] => 2008-04-08 00:18:08 [out_date] => 2008-06-21 [price] => 24.99 ) stdClass Object ( [check_date] => 2008-04-08 00:18:14 [out_date] => 2008-06-28 [price] => 34.99 ) stdClass Object ( [check_date] => 2008-04-08 00:18:14 [out_date] => 2008-06-28 [price] => 24.99 ) how do I go about doing this? should I have something like while function which would echo the object? Any help or ideas is appreciated Link to comment https://forums.phpfreaks.com/topic/100112-solved-how-to-mail-an-object/ Share on other sites More sharing options...
Barand Posted April 8, 2008 Share Posted April 8, 2008 try $str = print_r ($objectArray, 1); echo '<pre>', $str, '</pre>'; Link to comment https://forums.phpfreaks.com/topic/100112-solved-how-to-mail-an-object/#findComment-511878 Share on other sites More sharing options...
GingerRobot Posted April 8, 2008 Share Posted April 8, 2008 Or rather: echo '<pre>'. $str. '</pre>'; Link to comment https://forums.phpfreaks.com/topic/100112-solved-how-to-mail-an-object/#findComment-511886 Share on other sites More sharing options...
Barand Posted April 8, 2008 Share Posted April 8, 2008 If you prefer. either way works Link to comment https://forums.phpfreaks.com/topic/100112-solved-how-to-mail-an-object/#findComment-511896 Share on other sites More sharing options...
GingerRobot Posted April 8, 2008 Share Posted April 8, 2008 I hate it when this happens. How have I been usng PHP this long and not know that you can also use commas to join strings when echoing?! Apologies - i thought it was a typo. Link to comment https://forums.phpfreaks.com/topic/100112-solved-how-to-mail-an-object/#findComment-511900 Share on other sites More sharing options...
Barand Posted April 8, 2008 Share Posted April 8, 2008 It doesn't concatenate, it's just echo with several arguments. Link to comment https://forums.phpfreaks.com/topic/100112-solved-how-to-mail-an-object/#findComment-511904 Share on other sites More sharing options...
GingerRobot Posted April 8, 2008 Share Posted April 8, 2008 Should probably read the manual first, eh? Ah well, learnt something new today. Link to comment https://forums.phpfreaks.com/topic/100112-solved-how-to-mail-an-object/#findComment-511908 Share on other sites More sharing options...
tomasd Posted April 8, 2008 Author Share Posted April 8, 2008 Thanks, I'll have a go with that and let you guys know! Link to comment https://forums.phpfreaks.com/topic/100112-solved-how-to-mail-an-object/#findComment-511931 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.