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:[EMAIL PROTECTED] 
Sent: 06 April 2006 00:47
To: Tanner Postert; php-general@lists.php.net
Subject: Re: [PHP] 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

Reply via email to