PHP Classes

Number to Word (currency): Spell Nigeria currency amounts in English

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 491 All time: 5,872 This week: 96Up
Version License PHP version Categories
num-2-word 1.0.1GNU General Publi...3.0Text processing, Finances
Description 

Author

This package is specific mainly for applications used in Nigeria Nigeria .

This class can spell Nigeria currency amounts in English.

It can take an amount value less than 1 billion and convert it to English words that spell the amount in Naira currency.

The converted amount text is displayed as part of the current script output.

Picture of adeniyi ibraheem
  Performance   Level  
Name: adeniyi ibraheem <contact>
Classes: 6 packages by
Country: Nigeria Nigeria
Age: 37
All time rank: 18819 in Nigeria Nigeria
Week rank: 215 Up8 in Nigeria Nigeria Up

Example

<?php
include 'function.php';
$con = new convert();
if(isset(
$_POST['s']))
{
   
$con->convet($_POST['a']);
}
?>
<form method="post" action="">
<input type="text" name="a" /><input type="submit" value="Convert to word" name ="s" />
</form>
<?php
/*
$d = '120.90';
$w = 0;
$num = 0;
$sd = explode(".", $d);//split
    if(strlen($sd[1]) > 2)
    {
        $sf = substr($sd[1],0, 3);
        $sa = ".".$sf;
        $w = round($sa, 2);
        $num = $sd[0] + $w;
    }
    else
    {
        $num= $sd[0].".".$sd[1];
    }
echo $num;
*/
$q = 1235;
$num2 = 0;
if(
strpos($q, ".") == TRUE)
{
$d = explode(".", $q);

    if(
$d[1] > 10)
    {
       
//add 0 to front
       
$r = round($q, 2);
       
$d1 = explode(".", $r);
        if(empty(
$d1[1]))
        {
            echo
$d1[0].".0";
        }
        else
        {
            if(
strlen($d1[1]) == 1)
            {
               
$num2 = $d1[0].".".$d1[1]."0";
            }
            else
            {
               
$num2 = $d1[0].".".$d1[1];
            }
        }
    }
    else
    {
   
//add 0 to back
       
$r = round($q, 2);
       
$d1 = explode(".", $r);
        if(empty(
$d1[1]))
        {
           
$num2 = $d1[0].".0";
        }
       
            if(
strlen($d1[1]) == 1)
            {
               
$num2 = $d1[0].".".$d1[1]."0" ;
            }
            else
            {
               
$num2 = $d1[0].".".$d1[1];
            }
    }
}
else
{
   
$num2 = $q.".00";
}
echo
$num2;
?>


  Files folder image Files (2)  
File Role Description
Plain text file function.php Class class that perform all functions of conversion
Accessible without login Plain text file index.php Example contains textbox that accept input

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:491
This week:0
All time:5,872
This week:96Up