21,886
社区成员
发帖
与我相关
我的任务
分享
$re = array(
"部门"=> array("检验科" ,"检验科"),
"开单医生"=> array("管理员","管理员"),
"登记时间"=> array("2018-10-29","2018-11-02"),
"材料费"=> array(NULL ,NULL),
"彩超费"=> array( NULL,NULL) ,
"其他费"=> array( '22.45',NULL)
);
$new_data = array();
$keys = array();
foreach ($re as $key => $value) {
if (empty(array_filter($value))) {
continue;
}
$keys[] = $key;
$new_data[] = $value;
}
array_unshift($new_data, null);
$new_data = call_user_func_array('array_map', $new_data);
//创建表格将数组循环输入
echo '<table border="1" width="600" align="center">';
echo '<tr bgcolor="#dddddd">';
foreach ($keys as $key =>$value)
{
echo "<th>{$value}</th>";
}
echo '</tr>';
foreach ($new_data as $key =>$value)
{
echo '<tr>';
foreach($value as $mn)
{
echo "<td>{$mn}</td>";
}
echo '</tr>';
}
echo '</table>';
$re = array(
"部门"=> array("检验科" ,"检验科"),
"开单医生"=> array("管理员","管理员"),
"登记时间"=> array("2018-10-29","2018-11-02"),
"材料费"=> array(NULL ,NULL),
"彩超费"=> array( NULL,NULL) ,
"其他费"=> array( '22.45',NULL)
);
$a = array_filter($re, function($v) {return $v != [null, null];});
$t = call_user_func_array('array_map', array_merge([null], $a));
echo '<table border="1" width="600" align="center">';
echo '<tr bgcolor="#dddddd">';
echo '<th>' . join('</th><th>', array_keys($a)) . '</th></tr>';
foreach($t as $v) echo '<tr><td>' . join('</td><td>', $v) . '</td></tr>';
echo '</table>';