001.phpt 461 B

123456789101112131415161718192021222324252627282930313233343536
  1. --TEST--
  2. Basic match expression functionality test
  3. --FILE--
  4. <?php
  5. function wordify($x) {
  6. return match ($x) {
  7. 0 => 'Zero',
  8. 1 => 'One',
  9. 2 => 'Two',
  10. 3 => 'Three',
  11. 4 => 'Four',
  12. 5 => 'Five',
  13. 6 => 'Six',
  14. 7 => 'Seven',
  15. 8 => 'Eight',
  16. 9 => 'Nine',
  17. };
  18. }
  19. for ($i = 0; $i <= 9; $i++) {
  20. print wordify($i) . "\n";
  21. }
  22. ?>
  23. --EXPECT--
  24. Zero
  25. One
  26. Two
  27. Three
  28. Four
  29. Five
  30. Six
  31. Seven
  32. Eight
  33. Nine