Uploader v2.4

An all around general purpose file uploader for CakePHP. Packaged as a stand alone plugin with file validation, file scanning and support for a wide range of basic mime types.

Recent Thoughts

Numword v1.4 (Log)
Uploaded: 09/22/2009
Requires: PHP 5
Tested On: PHP 5.2.5


View Manual:

Numword

Package: Number to Word Converter
Category: PHP & MySQL
Views: 2,988

A small script that can convert a number to its word equivalent. Can work with single numbers, multiple numbers, currency and within text blocks.

Numword is a play on words for: Number Word Converter.

Class Features:
  • Convert single or multiple numbers
  • Convert USD currency
  • Convert all numbers within a string
  • Supports up to octillions
Related Entries:

Top

1 - Converting Numbers


It's rather easy to convert numbers to a word. To do so you use the single() or multiple() methods. The single() method will accept 1 argument - which should be an integer - and will return its word equivalent. By default, all words are separated by a dash (-), but can be changed by editing the $sep property.

// Single
echo Numword::single(1234);
// one-thousand, two-hundred thirty-four


The multiple() method will take an array of integers as its first argument and will return an array with the respective words.

// Multiple
print_r(Numword::multiple(array(123,5643,64)));
/* Array
(
    [0] => one-hundred twenty-three
    [1] => five-thousand, six-hundred forty-three
    [2] => sixty-four
) */
Top

2 - Converting Currency


As of right now, the currency() method will take an amount and return it to its dollar word format. This only works for USD, but you could easily edit the currency() method and replace the $ and "dollars" with the currency text you wish.

// Currency
echo Numword::currency('$6934.34');
// six-thousand, nine-hundred thirty-four dollars and thirty-four cents
Top

3 - Converting Numbers Within A String


If for some reason you have a number stuck right in the middle of a string and can't convert that number by itself, you would use the block() method. The block() method will convert all numbers that are found within the given string.

// String
$string = 'I am 21 years old, but my friend is 23.';
echo Numword::block($string);
// I am twenty-one years old, but my friend is twenty-three.
Read the whole documentation? Download the script now and try it yourself! Return to the Top