Numbers to Words in PHP using PEAR package

pradeep's Avatar author of Numbers to Words in PHP using PEAR package
This is an article on Numbers to Words in PHP using PEAR package in PHP.
Some web applications need to display numbers in words, like e-commerce, shopping web applications, so PEAR brings a package named Numbers_Words which converts numbers to words in 2 lines of PHP code.
Checkout the example below.

Code: PHP
<?php
 require('Numbers/Words.php');
 
     $number = 100254;
     $nw = new Numbers_Words();
     $numw = $nw->toWords($number);
 
     print $numw;
 ?>

Output:
Code:
one hundred thousand two hundred fifty-four
More can be done with with Numbers_Words, like setting the locale so that the output is formatted according to the local, you can find Numbers_Words documentation here.
Light Poster
15Feb2007,12:13   #2
aswini_1978's Avatar
Dear Sandeep,

I would highly appreciate if u can help me by solve this query??

I am trying to convert number to words and for that I have to download the file

Numbers_Words.php from pear package.

But this file is not opening. Can u please tell me how to download this file so that I may use the function that u have mentioned.

THANKS A TON IN ADVANCE..

Warm regards,
Aswini
Delhi
Light Poster
15Feb2007,12:15   #3
aswini_1978's Avatar
Dear Pradeep,

I would highly appreciate if u can help me by solve this query??

I am trying to convert number to words and for that I have to download the file

Numbers_Words.php from pear package.

But this file is not opening. Can u please tell me how to download this file so that I may use the function that u have mentioned.

THANKS A TON IN ADVANCE..

Warm regards,
Aswini
Delhi[/QUOTE]
Team Leader
15Feb2007,12:22   #4
pradeep's Avatar
Firstly you need to install PEAR, you'll find the instructions here http://pear.php.net/manual/en/installation.getting.php

then you need to install the Numbers_Words package using the PEAR installer.You'll find the instructions here http://pear.php.net/manual/en/installation.cli.php
Newbie Member
16Feb2007,19:52   #5
01soft's Avatar
try visit this code
from http://www.reconn.us/count_words.html
Code:
function adv_count_words($str) 
{
  $words = 0;
  $str = eregi_replace(" +", " ", $str);
  $array = explode(" ", $str);
  for($i=0;$i < count($array);$i++)
  {
    if (eregi("[0-9A-Za-zÀ-ÖØ-öø-ÿ]", $array[$i])) 
      $words++;
  }
  return $words;
}

Last edited by shabbir; 16Feb2007 at 22:08.. Reason: Code formatting.
Light Poster
31May2007,13:34   #6
aswini_1978's Avatar
Hi
Can u pls let me know how to calculate no. of weeks between 2 dates as I have to make MIS report on the basisi of weeks.

That means weekly report of collections.

Thanks a ton in advance