Codeigniter日历类

时间:2013-12-27 08:42:05

标签: php codeigniter date

我正在尝试在日历类的所有日子添加链接,但我不知道怎么做: 实际的代码允许我添加像这个例子中的特定链接,我想每天都添加linkk ...

$this->load->library('calendar');

$data = array(
           3  => 'http://example.com/news/article/2006/03/',
           7  => 'http://example.com/news/article/2006/07/',
           13 => 'http://example.com/news/article/2006/13/',
           26 => 'http://example.com/news/article/2006/26/'
         );

echo $this->calendar->generate(2006, 6, $data);

感谢您的帮助

2 个答案:

答案 0 :(得分:3)

这是你的答案

$this->load->library('calendar');
$month   = '2';
$year    = '2012';
$lastday = cal_days_in_month(CAL_GREGORIAN, $month, $year);
for ($day = 1; $day <= $lastday; $day++) {
    $prefix = ($day < 10) ? '0':'';
    $data[$day] =  'http://example.com/news/article/'.$year.'/'.$prefix.$day.'/';
}       
echo $this->calendar->generate($year, $month , $data);

答案 1 :(得分:0)

我会使用while循环或其他东西:

$days = 31;
$day = 1;
$month = 12;
$year = 2013;
$arr = array();

While ($day <= $days) {
    $arr[$day] = "'http://example.com/news/article/".$year."/".$month."/".$day;
}