亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

PHP開(kāi)發(fā)之制作簡(jiǎn)單日歷設(shè)置table中的tr與td

113.png

設(shè)置draw方法,畫(huà)表格,設(shè)置table中的tr與td

  1)數(shù)據(jù)將要用table標(biāo)簽來(lái)顯示,所以這里要將各個(gè)tr下面的td排列好

  2)$index % 7 == 0 計(jì)算表格每行的第一列

  3)$index % 7 == 6 || $index == ($length-1) 計(jì)算每行的最后一列,或$caculate的最后一個(gè)數(shù)據(jù)

  4)將中間行添加到$tr中,就是每一行的array

<?php
function draw($caculate) {  //$caculate 通過(guò)caculate方法計(jì)算后的數(shù)據(jù)
      $tr = array();
      $length = count($caculate);
      $result = array();
      foreach ($caculate as $index => $date) {
         if($index % 7 == 0) {//第一列
            $tr = array($date);
         }elseif($index % 7 == 6 || $index == ($length-1)) {
            array_push($tr, $date);
            array_push($result, $tr);//添加到返回的數(shù)據(jù)中
            $tr = array();//清空數(shù)組列表
         }else {
            array_push($tr, $date);
         }
      }
      return $result;
   }

?>


繼續(xù)學(xué)習(xí)
||
<?php function draw($caculate) { //$caculate 通過(guò)caculate方法計(jì)算后的數(shù)據(jù) $tr = array(); $length = count($caculate); $result = array(); foreach ($caculate as $index => $date) { if($index % 7 == 0) {//第一列 $tr = array($date); }elseif($index % 7 == 6 || $index == ($length-1)) { array_push($tr, $date); array_push($result, $tr);//添加到返回的數(shù)據(jù)中 $tr = array();//清空數(shù)組列表 }else { array_push($tr, $date); } } return $result; } ?>
提交重置代碼