reset_variation3.phpt 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. --TEST--
  2. Test reset() function : usage variations - Referenced variables
  3. --FILE--
  4. <?php
  5. /*
  6. * Reference two arrays to each other then call reset() to test position of
  7. * internal pointer in both arrays
  8. */
  9. echo "*** Testing reset() : usage variations ***\n";
  10. $array1 = array ('zero', 'one', 'two');
  11. echo "\n-- Initial position of internal pointer --\n";
  12. var_dump(current($array1));
  13. // Test that when two variables are referenced to one another
  14. // the internal pointer is the same for both
  15. $array2 = &$array1;
  16. next($array1);
  17. echo "\n-- Position after calling next() --\n";
  18. echo "\$array1: ";
  19. var_dump(current($array1));
  20. echo "\$array2: ";
  21. var_dump(current($array2));
  22. echo "\n-- Position after calling reset() --\n";
  23. var_dump(reset($array1));
  24. echo "\$array1: ";
  25. var_dump(current($array1));
  26. echo "\$array2: ";
  27. var_dump(current($array2));
  28. ?>
  29. --EXPECT--
  30. *** Testing reset() : usage variations ***
  31. -- Initial position of internal pointer --
  32. string(4) "zero"
  33. -- Position after calling next() --
  34. $array1: string(3) "one"
  35. $array2: string(3) "one"
  36. -- Position after calling reset() --
  37. string(4) "zero"
  38. $array1: string(4) "zero"
  39. $array2: string(4) "zero"