PHP Classes
elePHPant
Icontem

File: index.php

Recommend this page to a friend!
  Classes of adeniyi ibraheem  >  Number to Word (currency)  >  index.php  >  Download  
File: index.php
Role: Unit test script
Content type: text/plain
Description: contains textbox that accept input
Class: Number to Word (currency)
Spell Nigeria currency amounts in English
Author: By
Last change:
Date: 6 years ago
Size: 1,211 bytes
 

Contents

Class file image Download
<?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;
?>