simple_table() html()
A two-column key / value table from an array, with callbacks for the key cell and row or cell attributes.
html()->simple_table($replace = [], $extra = [])Опції
| Опція | Значення |
|---|---|
$replace | Key => value rows (values are developer HTML). |
key | ['func' => fn ($key) => ..., 'extra' => ['width' => '20%']]: render the key cell. |
tr | Callback fn ($row, $id) returning row attributes (string or array). |
td | Callback fn ($row, $name, $row_id) returning cell attributes. |
Приклад
| Order | 1001 |
| Status | Paid |
| Total | $174.90 |
Код
return html()->simple_table([
'Order' => '1001',
'Status' => 'Paid',
'Total' => '$174.90',
], [
'key' => ['func' => fn ($in) => '<b>' . $in . '</b>', 'extra' => ['width' => '20%']],
'tr' => fn ($row, $id) => $id === 2 ? ['class' => 'success'] : '',
'td' => fn ($row, $name, $row_id) => $row_id === 1 && $name === 'key' ? ['class' => 'info'] : '',
]);Див. також: html/dd_table, table/table