count_basic.phpt 1021 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. --TEST--
  2. Test count() function : basic functionality
  3. --FILE--
  4. <?php
  5. /*
  6. * Test basic functionality of count() using an array as $var argument
  7. * and different values as $mode argument.
  8. */
  9. echo "*** Testing count() : basic functionality ***\n";
  10. echo "\n-- One Dimensional Array: --\n";
  11. $array = array('zero', 'one', 'two');
  12. var_dump(count($array));
  13. echo "\n-- Two Dimensional Array: --\n";
  14. $array_multi = array('zero', array(1, 2, 3), 'two');
  15. echo "\$mode = COUNT_NORMAL: ";
  16. var_dump(count($array_multi, COUNT_NORMAL));
  17. echo "\$mode = 0: ";
  18. var_dump(count($array_multi, 0));
  19. echo "\$mode = COUNT_RECURSIVE: ";
  20. var_dump(count($array_multi, COUNT_RECURSIVE));
  21. echo "\$mode = 1: ";
  22. var_dump(count($array_multi, 1));
  23. echo "Done";
  24. ?>
  25. --EXPECT--
  26. *** Testing count() : basic functionality ***
  27. -- One Dimensional Array: --
  28. int(3)
  29. -- Two Dimensional Array: --
  30. $mode = COUNT_NORMAL: int(3)
  31. $mode = 0: int(3)
  32. $mode = COUNT_RECURSIVE: int(6)
  33. $mode = 1: int(6)
  34. Done