What I Need
url of image : http://i.stack.imgur.com/YViEQ.png .
Array Structure As Follows
Array
(
[0] => Array(
[type] => [metadata] => Array(
[0] => Array(
[0] => [1] =>
)
)
)
[1] => Array(
[type] => General Public Tickets Adult[metadata] => Array(
[0] => Array(
[0] => (Working Days)[1] => 50
)
[1] => Array(
[0] => (Saturday / Sunday / Holiday)[1] => 80
)
)
)
[2] => Array(
[type] => General Public Tickets Child: (5 - 12 years of age)[metadata] => Array(
[0] => Array(
[0] => Working Days[1] => 30
)
[1] => Array(
[0] => (Saturday / Sunday / Holiday)[1] => 50
)
)
)
[3] => Array(
[type] => Business Tickets[metadata] => Array(
[0] => Array(
[0] => Per Person Per Day(November 14 - 18, 2014)[1] => 400
)
[1] => Array(
[0] => multiple entry(validity: November 14 - 27, 2014)[1] => 1500
)
)
)
)
html code
<h2>Entry Fee</h2>
<table class="tb not-mobile" width="800" cellpadding="1" cellspacing="1" border="1">
<tr>
<td width="30%" rowspan="2">General Public Tickets Adult</td>
<td width="58%">(Working Days)</td>
<td width="12%" class="aligncenter">50</td>
</tr>
<tr>
<td>(Saturday/ Sunday/ Holiday)</td>
<td class="aligncenter">80</td>
</tr>
<tr>
<td rowspan="2">General Public Tickets Child : (5 - 12 years of age) </td>
<td>Working Days</td>
<td class="aligncenter">30</td>
</tr>
<tr>
<td>(Saturday/ Sunday/ Holiday)</td>
<td class="aligncenter">50</td>
</tr>
<tr>
<td rowspan="2"> Business Tickets </td>
<td>Per Person Per Day (November 14-18, 2014)</td>
<td class="aligncenter">40</td>
</tr>
<tr>
<td>multiple entry (validity : November 14-27, 2014)</td>
<td class="aligncenter">1500</td>
</tr>
</table>
code i have tried
print '<table width="800" cellpadding="1" cellspacing="1" border="1">';
foreach($result as $place => $task) {
//print_r($task);
$i = 0;
print "<tr>
<td width='30%' rowspan=".$place.">
".$task['type']."
</td>
<td width='58%'>
".$task['type']."
</td>
<td width='12%' class='aligncenter'>
".$task['type']."
</td>
</tr>";
foreach($task as $thingToDo) {
print_r($thingToDo);
$i++;
if ($i == 2) {
print "<tr>";
print "<td>".$thingToDo.
"</td>";
print "<td class='aligncenter'>".$thingToDo.
"</td>";
print "</tr>";
$i = 0;
} else {
print "<tr>";
print "<td>".$thingToDo[$i].
"</td>";
print "<td class='aligncenter'>".$thingToDo.
"</td>";
print "</tr>";
}
}
}
print " </table>";
Alternatively, you could nest another table inside that. Example:
<table border="1" cellpadding="0" cellspacing="0">
<?php foreach($array as $val1): ?>
<tr>
<td><?php echo $val1['type']; ?>
<td ><table border="0" width="100%" cellspacing="0">
<?php foreach($val1['metadata'] as $metadata): ?>
<tr>
<td><?php echo $metadata[0]; ?></td>
<td><?php echo $metadata[1]; ?></td>
</tr>
<?php endforeach; ?></table></td>
</tr>
<?php endforeach; ?>
</table>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.