Skip to content

Instantly share code, notes, and snippets.

@rkyoku
Last active October 4, 2019 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rkyoku/ff9dc34fa91c2a0bf8b968d312b4d8fb to your computer and use it in GitHub Desktop.
Save rkyoku/ff9dc34fa91c2a0bf8b968d312b4d8fb to your computer and use it in GitHub Desktop.
$aTest = array(
5 => array('pseudo' => 'donald'),
200 => array('pseudo' => 'mickey')
);
echo 'Before script';
var_dump($aTest);
foreach ($aTest as $iId => &$aData)
$aData['test'] = $iId;
// Should unset $aData here!! References are tricky
echo 'After reference loop';
var_dump($aTest);
foreach ($aTest as $iId => $aData)
;
echo 'After same variable name loop but no reference';
var_dump($aTest);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment