Skip to content

Instantly share code, notes, and snippets.

@stealth35
Created October 25, 2011 17:02
Show Gist options
  • Save stealth35/1313500 to your computer and use it in GitHub Desktop.
Save stealth35/1313500 to your computer and use it in GitHub Desktop.
PHP Iterator refcount crash
<?php
$tree = array();
$branch = &$tree;
$courses = array(
'f1' => '/d1',
'f6' => '/d2',
'f7' => '/d3',
'f8' => '/d3/d4',
'f9' => '/d3/d4',
);
foreach($courses as $id => $course) {
$path = explode('/', substr($course, 1));
$branch = &$tree;
foreach($path as $category) {
if (!isset($branch[$category])) {
$branch[$category] = array();
}
$branch = &$branch[$category];
}
$branch[] = $id;
}
$iterator = new RecursiveIteratorIterator(
new RecursiveArrayIterator($tree),
RecursiveIteratorIterator::SELF_FIRST
);
foreach($iterator as $file);
// exit; // uh ?
@stealth35
Copy link
Author

Crash without exit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment