<?php $doesNotMatter = ['a' => ['id' => 1], 'b' => ['id' => 2]]; $copy1 = $doesNotMatter; $reference = &$doesNotMatter['a']; $copy2 = $doesNotMatter; // Not a reference! var_dump($doesNotMatter); $copy1['a'] = null; $copy2['b'] = null; var_dump($doesNotMatter); $copy2['a'] = null; $copy2['b'] = null; // Intuitively, this should be a copy of $doesNotMatter and shouldn't affect it at all, but because a // reference exists to $doesNotMatter['a'] when $copy2 is created, that key is copied as a reference. // Basically, when a reference is created, PHP treats both the reference and the original as references, // and this affects object properties and array keys in unintuitive ways. var_dump($doesNotMatter);
You have javascript disabled. You will not be able to edit any code.