欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php?日历

程序员文章站 2022-06-10 12:07:11
...
每个事件对应一个开始日期和结束日期
如: 2015-10-05 2015-11-03 XXX 活动
那么当鼠标移动到这段日期时将显示 XXX活动

以下是我的思路,

会不会弄得太麻烦了


回复讨论(解决方案)

你可以在继续研究下

你可以在继续研究下


思路是正确的!
但实现时可以使用些小技巧

$d = '2015-11-01';//查表得到$a = array(  array('event_start_date' => '2015-11-07', 'event_end_date' => '2015-11-15'),  array('event_start_date' => '2015-11-17', 'event_end_date' => '2015-11-20'),);$t = array_fill(1, date('t', strtotime($d)), '');foreach($a as $v) {  $s = date('d', strtotime($v['event_start_date']));  $e = date('d', strtotime($v['event_end_date']));  $t = array_fill( $s, $e - $s + 1, 'event') + $t;}ksort($t);print_r($t);
得到数组
Array(    [1] =>     [2] =>     [3] =>     [4] =>     [5] =>     [6] =>     [7] => event    [8] => event    [9] => event    [10] => event    [11] => event    [12] => event    [13] => event    [14] => event    [15] => event    [16] =>     [17] => event    [18] => event    [19] => event    [20] => event    [21] =>     [22] =>     [23] =>     [24] =>     [25] =>     [26] =>     [27] =>     [28] =>     [29] =>     [30] => )
相关标签: php?日历