我在 web 服务中重新编码一些 json 对象,我在本地测试,所有的东西都很好,
但是当我将它上传到实时服务器上时,它会将我的数组更改为一个包含所有索引为的对象的单个对象,
这是我的代码
foreach ( $events as $eventkey => $event ) {
if ( $event->recurring_type == "DAILY" ) {
$date = new DateTime( $event->recurring_start_date );
$new_event = $event;
if ( $event->recurring_start_date < $event->recurring_end_date ) {
while ( $new_event->recurring_start_date < $new_event->recurring_end_date ) {
$new_event->event_date = $new_event->recurring_start_date;
$events[] = (array) $new_event;
$new_event->recurring_start_date = $date->modify('+1 day')->format('Y-m-d H:i:s');
}
} else {
unset( $events[$eventkey] ); // used to avoid duplicate result with same data event_date,
}
}
如果我删除这条线
unset( $events[$eventkey] );
然后,结果在网上也很好。但我需要这个!我无法理解确切的问题!
请帮忙