我正在使用引用来更改数组:
foreach($uNewAppointments as &$newAppointment)
{
foreach($appointments as &$appointment)
{
if($appointment == $newAppointment){
$appointment['index'] = $counter;
}
}
$newAppointment['index'] = $counter;
$newAppointments[$counter] = $newAppointment;
$counter++;
}
如果我打印数组内容,那么我会收到预期的结果。当我迭代它时,所有元素似乎都是相同的(第一个)。
当我删除内部数组中的引用运算符&时,一切正常,除了未设置索引。