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
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;

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.