}
* @param array $data {list>}
*/
function table(
array $titles,
array $data
) : string
{
$html = '';
$html .= ("\n");
if (! is_null($titles)) {
$html .= ("\n");
$html .= sprintf(
"%s
\n",
implode(
'',
array_map(
function (string $title) : string {
return sprintf(
"%s | ",
$title
);
},
$titles
)
)
);
$html .= ("\n");
}
{
$html .= ("\n");
foreach ($data as $line) {
$html .= sprintf(
"%s
\n",
implode(
'',
array_map(
function (string $field) : string {
return sprintf(
"%s | ",
$field
);
},
$line
)
)
);
}
$html .= ("\n");
}
$html .= ('
' . "\n");
return $html;
}
?>