Jump to content

Recommended Posts

Yep. You can do an array that just has the unique numbers that you need, though:

$numbers = array("Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety");

 

Link to comment
https://forums.phpfreaks.com/topic/112792-making-a-list/#findComment-579300
Share on other sites

try

<?php
function num_to_word($num, $tri=0) {
$ones = array("", " one", " two", " three", " four", " five", " six", " seven", " eight", " nine", " ten", " eleven", " twelve", " thirteen", " fourteen", " fifteen", " sixteen", " seventeen", " eighteen", " nineteen");
$tens = array("", "", " twenty", " thirty", " forty", " fifty", " sixty", " seventy", " eighty", " ninety");
$triplets = array("", " thousand", " million", " billion");
$r = (int) ($num / 1000);
$x = ($num / 100) % 10;
$y = $num % 100;
$str = "";
if ($x > 0) $str = $ones[$x] . " hundred";
if ($y < 20) $str .= $ones[$y]; else $str .= $tens[(int) ($y / 10)] . $ones[$y % 10];
if ($str != "") $str .= $triplets[$tri];
if ($r > 0) return convertTri($r, $tri+1).$str; else return $str;
}
for ($i = 1; $i<=50; $i++) $out[$i] = ucfirst(trim(num_to_word($i)));
print_r($out);
?>

Link to comment
https://forums.phpfreaks.com/topic/112792-making-a-list/#findComment-579363
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.