1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| if ( ! empty($extractData['arryTable']))
{
$html = array();
// fonction d'échappement des caractères pour l'utf-8
$hsc = function($p) { return htmlspecialchars($p, ENT_QUOTES, 'utf-8'); };
// fonction de rendu d'une case de tableau en y incluant l'échappement
$table_row = function($p, $tag) use ($hsc) { return "<{$tag}>{$hsc($p)}</{$tag}>"; };
foreach ($extractData['arryTable'] as $id => $array)
{
foreach ($array as $label => $array2)
{
$html[] = "<h2>{$hsc($label)}</h2>";
$html[] = '<table>';
foreach ($array2 as $row => $value)
{
if ($row == 0)
{
$html[] = '<thead>';
$html[] = '<tr>'.implode("\n", array_map($table_row($p, 'th'), $value)).'</tr>';
$html[] = '</thead>';
$html[] = '<tbody>';
}
else
{
$html[] = '<tr>'.implode("\n", array_map($table_row($p, 'td'), $value)).'</tr>';
};
}
$html[] = '</tbody>';
$html[] = '</table>';
}
}
echo implode("\n", $html);
} |