php ::Array references

josie

New Member
any idea why\[code\]foreach ($groups as &$group) $group = trim(str_replace(',', '', $group));echo '<pre>';print_r($groups);echo '</pre>';$groupsq = $groups;foreach ($groupsq as &$group) $group = '\'' . $group . '\'';echo '<pre>';print_r($groups);echo '</pre>';\[/code\]Yields\[code\]Array( [0] => Fake group [1] => another group [2] => non-existent)Array( [0] => Fake group [1] => another group [2] => 'non-existent')\[/code\]The part i am interested in is,Why does the second array modification effect the last item on the first array?
 
Back
Top