PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Barida Popsana   Arabic Number English Translation   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example file for Number to word
Class: Arabic Number English Translation
Convert numbers to English words
Author: By
Last change:
Date: 11 years ago
Size: 1,018 bytes
 

Contents

Class file image Download
<?php

/**
 * Description of Example
 *
 * @author Barida Popsana
 * http://popsypedia.org/
 */

 //First of all, include or require the class into your working file..
 
require_once "numberToWord.php";
 
 
 
//Now, we need a number to work with..
 
$number = 573021;
 
 
 
//Now, we create a new instance of the numberToWord class..
 //The constructor takes the number to be converted as an optional parameter..
 
 
$ntw = new numberToWord( $number );
 
 
 
//Example 1:
 //Get the converted string..
 
$word = $ntw->convert();
 echo
$word; //Prints Five hundred and seventy-three thousand and twenty one
 
 //Example 2:
 
 /*
    If you had more than one number, you don't have to create a new instance of the numberToWord class every time as shown below:
 */
 
 
$mynumbers = array( 33000, 45201, 24095, 4496069, 8840394120 );
 
 
$ntw = new numberToWord( $number );
 
 foreach(
$mynumbers as $mn ) {
   
$word = $ntw->convert( $mn );
    echo
$word; //Echoes the converted string..
 
}

?>