<?php
/*使用PHP创建一个数组,保存5個员工的信息(ename/sex/salary/birthday/pic)*/
$empList=[
['ename'=>'张学友','sex'=>'男','salary'=>200,'birthday'=>12354215451215,'pic'=>'img/1.jpg'],
['ename'=>'张启山','sex'=>'男','salary'=>12000,'birthday'=>12354215451215,'pic'=>'img/1.jpg'],
['ename'=>'张乌鸡','sex'=>'男','salary'=>8880,'birthday'=>12354215451215,'pic'=>'img/1.jpg'],
['ename'=>'张韶涵','sex'=>'女','salary'=>4000,'birthday'=>12354215451215,'pic'=>'img/1.jpg'],
['ename'=>'张天师','sex'=>'男','salary'=>123256,'birthday'=>12354215451215,'pic'=>'img/1.jpg']
];
?>
<table>
<tbody>
<?php
for($i=0; $i<count($empList);$i++){ //count()函数计算$empList里面的个数
$e=$empList[$i];
echo "<tr>";
echo "<td>$e[ename]</td>";
echo "<td>$e[sex]</td>";
echo "<td>$$e[salary]</td>";
echo "<td>$e[birthday]</td>";
echo "<td>$e[pic]</td>";
echo "</tr>";
}
?>
</tbody>
</table>
<script>
//输出queryselectorall()获取文档中指定元素的nth上到下顺序第四个td元素取值;
var td_03=document.querySelectorAll('td:nth-child(4)');
console.log(td_03);
for(var i=0; i<td_03.length;i++){ //遍历td_03
var td=td_03[i]; //获取当期遍历元素,赋值给td;
var num=parseInt(td.innerHTML); //把td在页面显示为整数类型添加到num中
var d=new Date(); //获取当前时间
td.innerHTML= d.getFullYear()+'-'+(d.getMonth()+1)+'-'+ d.getDate();
//在页面显示时间格式
}
</script>