Skip to content

Instantly share code, notes, and snippets.

@nervetattoo
Created May 4, 2011 08:48
Show Gist options
  • Save nervetattoo/954945 to your computer and use it in GitHub Desktop.
Save nervetattoo/954945 to your computer and use it in GitHub Desktop.
Associativity and return by reference in PHP
<?php
$objects = array(new stdClass, new stdClass);
while ($o =& next($objects) && true)
var_dump($o); // stdClass object
reset($objects);
while ($o = next($objects) && true)
var_dump($o); // true
// Fix
reset($objects);
while (($o = next($objects)) && true)
var_dump($o); // stdClass object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment