```php
$headstr=[‘编号’,’姓名’,’年龄’,’地区’];
$strr=[
[‘id’=>1001,’name’=>’小梁’,’age’=>18,’area’=>’深圳’],[‘id’=>1002,’name’=>’小陈’,’age’=>22,’area’=>’珠海’],[‘id’=>1003,’name’=>’小明’,’age’=>25,’area’=>’东莞’],[‘id’=>1004,’name’=>’小新’,’age’=>20,’area’=>’惠州’]
];
function table_css($str,$headstr,$t_css){
$table_css="<table class='$t_css'>";
$table_css .="<thead>";
$table_css .="<tr>";
foreach($headstr as $h_value){
$table_css .="<th>" .$h_value;
$table_css .="</th>";
}
$table_css .="</tr>";
$table_css .="</thead>";
$table_css .="<tbody>";
foreach($str as $key => $value){
$table_css .="<tr>";
foreach($value as $key2 => $value2){
$table_css .="<td>" . $value2;
$table_css .="</td>";
}
$table_css .="</tr>";
}
$table_css .="</tbody>";
return $table_css;
}
echo table_css($strr,$headstr,'t_css');
?>
<style>
.t_css{
width:calc(100vw - 40px);
border: 1px solid #333;
border-collapse:collapse;
margin:0 auto;
}
.t_css td,.t_css th{
border: 1px solid #333;
text-align:center;
empty-cells: show;
padding:1rem;
}
.t_css thead{
background-color: #e0e0e0;
}
.t_css tbody > tr:nth-of-type(odd){
background-color: #f2f2f2;
}
/* tr:nth-type-of(2){
background-color:#000;
} */
</style>
```