Skip to content

Instantly share code, notes, and snippets.

@danpoltawski
Created May 10, 2012 05:10
Show Gist options
  • Save danpoltawski/2651157 to your computer and use it in GitHub Desktop.
Save danpoltawski/2651157 to your computer and use it in GitHub Desktop.
php references fun
<?php
$array = array(
new stdClass,
new stdClass
);
$count = 0;
foreach ($array as &$object) {
$object->count = $count;
$count++;
}
$object = new stdClass;
$object->newthing = 'Yep this is going into the referenced object';
echo '<pre>'.print_r($array, true).'<pre>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment