html - Can I loop inside a variable using HTML_Template_Sigma in PHP?
Get the solution ↓↓↓I have to use the HTML_Template_Sigma PEAR Module to do an assignment on PHP that basically wraps all the HTML of a website to make templates with it instead of pasting the same HTML over and over. The thing is that all the content is added using variables and at some point I have to loop through an array inside one of the string variables (which has a table inside). So I checked the documentation which is not really abundant and it does have some sort of loop implementation but oriented to publications and I don't know how to use it to solve my problem.
http://www.pixel2life.com/publish/tutorials/13/pear_module_html_template_sigma/
http://pear.php.net/manual/en/package.html.html-template-sigma.intro-syntax.php
Still what they show is not exactly the same as this.
foreach ($data as $result) {
$plantilla->setCurrentBlock('table_row');
$plantilla->setVariable(array(
'date' => $result[0],
'epicentre' => $result[1],
'region' => $result[2],
'richter' => $result[3],
'mercalli' => $result[4]
));
$plantilla->parseCurrentBlock('table_row');
}
This is my variable:
content = '
<table>
<thead>
<tr>
<th>Date</th>
<th>Epicentre</th>
<th>Region</th>
<th>Mw Richter</th>
<th>Mercalli</th>
</tr>
</thead>
<tbody>
<!-- BEGIN table_row -->
<tr>
<td>{date}</td>
<td>{epicentre}</td>
<td>{region}</td>
<td>{richter}</td>
<td>{mercalli}</td>
</tr>
<!-- END table_row -->
</tbody>
</table>';
My array contains 5 columns of data. I've tried but to no avail.
Thanks in advance!
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: gd library extension not available with this php installation.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.