prev_variation2.phpt 786 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. --TEST--
  2. Test prev() function : usage variation - Multi-dimensional arrays
  3. --FILE--
  4. <?php
  5. /*
  6. * Test prev() when passed:
  7. * 1. a two-dimensional array
  8. * 2. a sub-array
  9. * as $array_arg argument.
  10. */
  11. echo "*** Testing prev() : usage variations ***\n";
  12. $subarray = array(9,8,7);
  13. end($subarray);
  14. $array_arg = array ($subarray, 'a' => 'z');
  15. end($array_arg);
  16. echo "\n-- Pass a two-dimensional array as \$array_arg --\n";
  17. var_dump(prev($array_arg));
  18. var_dump(prev($array_arg));
  19. echo "\n-- Pass a sub-array as \$array_arg --\n";
  20. var_dump(prev($array_arg[0]));
  21. ?>
  22. --EXPECT--
  23. *** Testing prev() : usage variations ***
  24. -- Pass a two-dimensional array as $array_arg --
  25. array(3) {
  26. [0]=>
  27. int(9)
  28. [1]=>
  29. int(8)
  30. [2]=>
  31. int(7)
  32. }
  33. bool(false)
  34. -- Pass a sub-array as $array_arg --
  35. int(8)