WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : PHP: Convert Number To Words
Categories : PHP, Arrays, Beginner Guides Click here to Update Your Picture
Alex Culango
Date : Jun 11th 2010
Grade : 2 of 5 (graded 9 times)
Viewed : 12811
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Alex Culango
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
Like this code?
Show the author your appreciation.
 

Convert Number To Words

<?php
/***********************************************
* Script Name : NumToWords *
* Scripted By : Alex Culango *
* Email : itnapster.som@gmail.com *
***********************************************/
function numtowords($num){
$ones = array(
1 => "one",
2 => "two",
3 => "three",
4 => "four",
5 => "five",
6 => "six",
7 => "seven",
8 => "eight",
9 => "nine",
10 => "ten",
11 => "eleven",
12 => "twelve",
13 => "thirteen",
14 => "fourteen",
15 => "fifteen",
16 => "sixteen",
17 => "seventeen",
18 => "eighteen",
19 => "nineteen"
);
$tens = array(
2 => "twenty",
3 => "thirty",
4 => "forty",
5 => "fifty",
6 => "sixty",
7 => "seventy",
8 => "eighty",
9 => "ninety"
);
$hundreds = array(
"hundred",
"thousand",
"million",
"billion",
"trillion",
"quadrillion"
); //limit t quadrillion
$num = number_format($num,2,".",",");
$num_arr = explode(".",$num);
$wholenum = $num_arr[0];
$decnum = $num_arr[1];
$whole_arr = array_reverse(explode(",",$wholenum));
krsort($whole_arr);
$rettxt = "";
foreach($whole_arr as $key => $i){
if($i < 20){
$rettxt .= $ones[$i];
}elseif($i < 100){
$rettxt .= $tens[substr($i,0,1)];
$rettxt .= " ".$ones[substr($i,1,1)];
}else{
$rettxt .= $ones[substr($i,0,1)]." ".$hundreds[0];
$rettxt .= " ".$tens[substr($i,1,1)];
$rettxt .= " ".$ones[substr($i,2,1)];
}
if($key > 0){
$rettxt .= " ".$hundreds[$key]." ";
}
}
if($decnum > 0){
$rettxt .= " and ";
if($decnum < 20){
$rettxt .= $ones[$decnum];
}elseif($decnum < 100){
$rettxt .= $tens[substr($decnum,0,1)];
$rettxt .= " ".$ones[substr($decnum,1,1)];
}
}
return $rettxt;
}
echo numtowords("23431999.99");

?>



Human readable PHP password generator
Categories : PHP, Security, Beginner Guides, Arrays
Random text quote
Categories : PHP, Arrays, Beginner Guides
How to display any array in several rows and columns of a table. Not just in one column or in alternate rows. This example shows a nice color table generated with PHP, but can be used with any array values(e.g. Database)
Categories : Arrays, PHP, Miscellaneous, Beginner Guides, Graphics
Beginners Array Functions
Categories : PHP, Beginner Guides, Arrays
Link Submition - Allow your visitors to submit links to the site.
Categories : PHP, Arrays, Filesystem, Beginner Guides
Selecting a random line from a text file
Categories : PHP, Filesystem, Arrays, Beginner Guides
Form Submission Using Array's
Categories : PHP, HTML and PHP, Beginner Guides, Arrays
My Box - PHP Class that calculates the volumetric weight of a package.
Categories : PHP, Object Oriented, PHP Classes, Beginner Guides, Payment Gateways
Single-file PHP news system with automatic folder structure creation
Categories : PHP, Filesystem, Arrays
Parsing html tags with php. Get an array from this function
Categories : PHP, HTML and PHP, Arrays, Tag Extractors
Takes an array and returns a string, suitable for inputing in an SQL statement
Categories : Arrays, Strings, PHP
Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
Simple PHP Form Field Generator
Categories : PHP, Beginner Guides, Form Processing, HTML and PHP
Check for functional file links (broken Files)
Categories : PHP, Data Validation, FTP, Regexps, Arrays
Grab images from one or more URLs and save them to a specified local directory.
Categories : PHP, Filesystem, Strings, Arrays