这是循环:
foreach($event['Event']['user_id'] as $employee){
for($date; $date <= $end_date; $date = strtotime("+1 day", $date))
{
if(strpos($weekdays, date("N", $date)) !== false){
$real_date = date("Y-m-d", $date);
$event['Event']['date'] = $real_date;
$event['Event']['user_id'] = $employee;
$this->Event->create();
$this->Event->save($event);
debug($event['Event']['user_id']);
}
}
}
*$event['Event']['user_id']* 的内容如下:
array(
(int) 0 => '23',
(int) 1 => '24',
(int) 2 => '27',
(int) 3 => '28')
如果我尝试在 for 循环之前打印每个$employee,我会打印所有四条记录,但 for 循环仅适用于第一条记录。任何帮助深表感谢。
编辑:添加了pr($event)的结果
Array([Event] => Array
(
[project_id] => 62
[user_id] => Array
(
[0] => 23
[1] => 24
[2] => 27
[3] => 28
[4] => 29
)
[hours] => 4
[minutes] => 0
[assignment] =>
[material] =>
[date] => 2013-10-6
[start_time] => Array
(
[hour] => 09
[min] => 00
)
[finish_time] => Array
(
[hour] => 13
[min] => 00
)
[repeat] => 0
[finish_date] =>
[weekdays] =>
)
)