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. Quote Link to comment 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; Quote Link to comment 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; Quote Link to comment 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. Quote Link to comment 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.