我有你的背,夥伴。我剛剛更新了naomik/htmlgen與2.x版本。請參閱example目錄中的其他代碼。
use function htmlgen\html as h;
use function htmlgen\map;
$beeData = [
'pop' => 'yup',
'candy' => 'sometimes',
'flowers' => 'so much',
'water' => 'not really',
'sand' => 'indifferent',
'donuts' => 'most definitely'
];
echo h('table',
h('thead',
h('tr',
h('td', 'item'),
h('td', 'do bees like it?')
)
),
h('tbody',
map($beeData, function($value, $key) { return
h('tr',
h('td', $key),
h('td', $value)
);
})
)
);
輸出(空格不包括在實際輸出)
<table>
<thead>
<tr>
<td>item</td>
<td>do bees like it?</td>
</tr>
</thead>
<tbody>
<tr>
<td>pop</td>
<td>yup</td>
</tr>
<tr>
<td>candy</td>
<td>sometimes</td>
</tr>
<tr>
<td>flowers</td>
<td>so much</td>
</tr>
<tr>
<td>water</td>
<td>not really</td>
</tr>
<tr>
<td>sand</td>
<td>indifferent</td>
</tr>
<tr>
<td>donuts</td>
<td>most definitely</td>
</tr>
</tbody>
</table>
太好了!謝謝!,沒有想過要搜索GitHub,這當然是合乎邏輯的事情。一定是盲目的... – jwka 2014-10-20 14:20:03
@Jens,感謝您鏈接我的圖書館。它沒有維護一段時間,但我需要它,所以我只是給它一個大刷新。^__ ^ – naomik 2016-03-05 09:39:04