bug35022.phpt 501 B

123456789101112131415161718192021
  1. --TEST--
  2. Bug #35022 (Regression in the behavior of key/current functions)
  3. --FILE--
  4. <?php
  5. $state = array("one" => 1, "two" => 2, "three" => 3);
  6. function foo( &$state ) {
  7. $contentDict = end( $state );
  8. for ( $contentDict = end( $state ); $contentDict !== false; $contentDict = prev( $state ) ) {
  9. echo key($state) . " => " . current($state) . "\n";
  10. }
  11. }
  12. foo($state);
  13. reset($state);
  14. var_dump( key($state), current($state) );
  15. ?>
  16. --EXPECT--
  17. three => 3
  18. two => 2
  19. one => 1
  20. string(3) "one"
  21. int(1)