Edit report at https://bugs.php.net/bug.php?id=55185&edit=1
ID: 55185 Updated by: scott...@php.net Reported by: janwalther86 at gmail dot com Summary: SplMaxHeap only once loopable -Status: Open +Status: Bogus Type: Bug Package: SPL related PHP Version: 5.3.6 Block user comment: N Private report: N New Comment: As it iterates over a heap it extracts the number from it. Previous Comments: ------------------------------------------------------------------------ [2011-07-12 04:19:23] janwalther86 at gmail dot com Description: ------------ I tried to loop through a SplMaxHeap object multiple times but it only loops once. As there is no option to reset or rewind the heap object I don't see a way to loop through it multiple times. I noticed that $heap->count() decreases with every loop cycle, perhaps that is the reason. Test script: --------------- $heap = new SplMaxHeap(); $heap->insert(1); $heap->insert(2); foreach($heap as $number){ echo $number."\n"; } foreach($heap as $number){ echo $number."\n"; } Expected result: ---------------- 2 1 2 1 Actual result: -------------- 2 1 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=55185&edit=1