andz Posted June 15, 2010 Share Posted June 15, 2010 Hi, I have use an <<<EOD in my system and I've stumbled on this situation... How am i suppose to put foreach / loop inside the <<<EOD? Here's the piece of the code that I have. $msg = <<<EOD <table width="612px" height="792px" border="0" cellpadding="2" cellspacing="2" style="font-size:14px; font-family:Tahoma;"> <tr> <td height="150" valign="top" colspan="2" align="center"><img src="{$this->url}/images/policy/1.jpg" width="350" height="120" /></td> </tr> <tr> <td>i want to insert the foreach loop here.</td> </tr> </table> any piece of code will help. thanks a lot. Link to comment https://forums.phpfreaks.com/topic/204833-foreach-loop-inside-eod/ Share on other sites More sharing options...
Mchl Posted June 15, 2010 Share Posted June 15, 2010 You can't You can do womething like this however $loopResult = ""; foreach() { $loopResult .= ....; } $msg = <<<EOD <...> <td>$loopResult</td> EOD; Link to comment https://forums.phpfreaks.com/topic/204833-foreach-loop-inside-eod/#findComment-1072312 Share on other sites More sharing options...
andz Posted June 15, 2010 Author Share Posted June 15, 2010 You can't You can do womething like this however $loopResult = ""; foreach() { $loopResult .= ....; } $msg = <<<EOD <...> <td>$loopResult</td> EOD; hi, thanks for the reply. i already found a turnaround to it. i stored the value of the foreach into an array then called it inside the <<<EOD... below is the sample one. foreach ($child as $kid) { $row[] = $kid['fname']; } $imp = implode('<br />', $row); $msg = <<<EOD {$imp} EOD; Link to comment https://forums.phpfreaks.com/topic/204833-foreach-loop-inside-eod/#findComment-1072313 Share on other sites More sharing options...
Mchl Posted June 15, 2010 Share Posted June 15, 2010 Yeah, similar approach and works just as well. Link to comment https://forums.phpfreaks.com/topic/204833-foreach-loop-inside-eod/#findComment-1072558 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.