PHP development to create a simple calendar setting tr and td in the table

Set the draw method, draw the table, and set the tr and td in the table
1) The data will be displayed using the table tag, so here you need to set the tr and td under each tr. td arranged
2)$index % 7 == 0 Calculate the first column of each row of the table
3)$index % 7 == 6 || $index == ($length -1) Calculate the last column of each row, or the last data of $caculate
4) Add the middle row to $tr, which is the array
<?php
function draw($caculate) { //$caculate 通过caculate方法计算后的数据
$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);//添加到返回的数据中
$tr = array();//清空数组列表
}else {
array_push($tr, $date);
}
}
return $result;
}
?>
# of each row ##
new file
<?php
function draw($caculate) { //$caculate 通过caculate方法计算后的数据
$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);//添加到返回的数据中
$tr = array();//清空数组列表
}else {
array_push($tr, $date);
}
}
return $result;
}
?>
Preview
Clear
- Course Recommendations
- Courseware download
The courseware is not available for download at the moment. The staff is currently organizing it. Please pay more attention to this course in the future~
Students who have watched this course are also learning
Let's briefly talk about starting a business in PHP
Quick introduction to web front-end development
Large-scale practical Tianlongbabu development of Mini version MVC framework imitating the encyclopedia website of embarrassing things
Getting Started with PHP Practical Development: PHP Quick Creation [Small Business Forum]
Login verification and classic message board
Computer network knowledge collection
Quick Start Node.JS Full Version
The front-end course that understands you best: HTML5/CSS3/ES6/NPM/Vue/...[Original]
Write your own PHP MVC framework (40 chapters in depth/big details/must read for newbies to advance)
















