The code below loops through the $count variable and increases as long as it's less than 14. Odd numbers are written in words while even numbers are written in numbers, separated by commas.
I want the last number in the loop(14) to end with a period(.) instead of a comma(,), how do I do that?
Code:
<?php
$count = 0;
while ($count<=14){
if ($count&1) {
$numword = new NumberFormatter("en", NumberFormatter::SPELLOUT);
echo $numword->format($count).", ";
} elseif ($count%2==0) {
echo "{$count}, ";
} else {
echo "{$count}, ";
}
$count++;
}
?>
Output:
0, one, 2, three, 4, five, 6, seven, 8, nine, 10, eleven, 12, thirteen, 14,