参照を使用して配列を変更しています:
foreach($uNewAppointments as &$newAppointment)
{
foreach($appointments as &$appointment)
{
if($appointment == $newAppointment){
$appointment['index'] = $counter;
}
}
$newAppointment['index'] = $counter;
$newAppointments[$counter] = $newAppointment;
$counter++;
}
配列の内容を出力すると、期待どおりの結果が得られます。それを繰り返すと、すべての要素が同じように見えます (最初の要素)。
内部配列の参照演算子&を削除すると、インデックスが設定されていないことを除いて、すべて正常になります。