有时候调试数据,需要表格呈现时,可参照以下例程。
public function generate() {
$teams = ['曼联', '曼城', '阿仙奴', '巴塞', '皇马', '拜仁'];
$schedule = schedule($teams);
$tables = [];
foreach ($schedule as $key => $round) {
$content = array(
'#type' => 'table',
'#sticky' => FALSE,
'#header' => ['A队', 'B队'],
);
$rows = [];
foreach($round as $match) {
$rows[] = array($match[0], $match[1]);
}
$content['#rows'] = $rows;
$tables[] = $content;
}
return $tables;
}
评论