Heim >Backend-Entwicklung >PHP-Tutorial >php做日历for循环排序问题

php做日历for循环排序问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-06 20:18:561867Durchsuche

大家新年好,请看代码

<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>

输出如下,应该空格->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>

输出如下,应该空格->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>
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn