热搜:NVER node 开发 php

php?日历

2024-07-28 09:50:02
php?日历


每个事件对应一个开始日期和结束日期
如: 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] => )