当我写一些代码时,PHP 让我有些困惑,因为我没有预料到以下代码的结果:
$data = array(array('test' => 'one'), array('test' => 'two'));
foreach($data as &$entry) {
$entry['test'] .= '+';
}
foreach($data as $entry) {
echo $entry['test']."\n";
}
我认为它应该输出
one+
two+
然而结果是:http: //ideone.com/e5tCsi
one+
one+
谁能向我解释为什么?