RE: int to string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Won't work

20 would become 'two zero' not 'twenty' as the for loop identifies 1
character at a time

Don't have any suggestions... Just critisms :-D... hehe sorry

Dan
 
-------------------
http://chrome.me.uk
 

-----Original Message-----
From: Peter Hoskin [mailto:peterh@xxxxxxxxxx] 
Sent: 06 April 2006 00:47
To: Tanner Postert; php-general@xxxxxxxxxxxxx
Subject: Re:  int to string

Tanner Postert wrote:
> I don't think it's built in, so I was wondering ya'll would recommend as
the
> best way to convert int to string, not basic type casting, but converting
to
> the english word the int represents.
>
> Something like this:
>
> 5 = "Five" or 20 = "Twenty"
>   
You're right - its not built in.

You could use something like this

function numerictotext($numeric) {
  for ($i;$i < strlen($numeric);$i++) {
    $character = substr($numeric,$i,1);
    switch ($character) {
      case 0:
        $return .= 'Zero ';
        break;
      case 1:
        $return .= 'One ';
        break;
    }
  }
  return $return;
}

Regards,
Peter Hoskin
Do I get a cookie?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


__________ NOD32 1.1474 (20060405) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux