php做日历for循环排序问题

WBOY
Release: 2016-06-06 20:18:56
Original
1826 people have browsed it

大家新年好,请看代码

<code>    for ($i=1; $i  ";
        }
        for ($j=1; $j ";
            }
            $html .= "<li>$j</li>";
        
        }
            // while(($j+$i-1)%7 !=0){
            //     $html .= "<li> </li>";
            //     $j++;
            // }
        return $html;</code>
Copy after login
Copy after login

输出如下,应该空格->6分开才对啊?为什么显示到5呢
空白
1
2
3
4
5

6
7
8
9
10
11
12

13
14
15
16
17
18
19

20
21
22
23
24
25
26

27
28
29

回复内容:

大家新年好,请看代码

<code>    for ($i=1; $i  ";
        }
        for ($j=1; $j ";
            }
            $html .= "<li>$j</li>";
        
        }
            // while(($j+$i-1)%7 !=0){
            //     $html .= "<li> </li>";
            //     $j++;
            // }
        return $html;</code>
Copy after login
Copy after login

输出如下,应该空格->6分开才对啊?为什么显示到5呢
空白
1
2
3
4
5

6
7
8
9
10
11
12

13
14
15
16
17
18
19

20
21
22
23
24
25
26

27
28
29

感觉我这个好看点,不用指定年月,
代码在:https://github.com/rainwsy/sf/blob/master/sf-1010000004408581.php

php做日历for循环排序问题

按列表分页来做比较好理解,直接撸...

<code class="php"><?php $li_total = 29; //一月总天数
$page_size = 7; //一周
$li_start = 2;  //第一天开始位置
$li_all = $li_total+$li_start;
$page_total = ceil($li_all/$page_size);

$html = "<ul>";
for($s=0;$s";
}

for($i=0;$i0?"<ul>":"";
    $s = $i>0?0:$s;
    for($j=$s;$j$k":"";
    }
    $html .= "</ul>";
}
echo $html;</code>
Copy after login
Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template