Jump to content

foreach loop inside EOD


andz

Recommended Posts

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

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;

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.