1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Numbers to Words in PHP using PEAR package

Discussion in 'PHP' started by pradeep, Nov 9, 2006.

  1. pradeep

    pradeep Team Leader

    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.

    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.
     
  2. aswini_1978

    aswini_1978 New Member

    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
     
  3. aswini_1978

    aswini_1978 New Member

    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]
     
  4. pradeep

    pradeep Team Leader

  5. 01soft

    01soft New Member

    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 a moderator: Feb 16, 2007
  6. aswini_1978

    aswini_1978 New Member

    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
     
  7. pradeep

    pradeep Team Leader

Share This Page