# Convert Numbers into words

Convert Numbers into words

```<?php

/*Coded By Amir Salah :-) */

\$num = 531; /* The Number */

\$leng = strlen(\$num); /* The Length */

/* ones Function */
function one(\$num){
\$one     = substr(\$num, -1, 1);
return \$one;
}
/* tens Functions */
function ten(\$num){
\$ten     = substr(\$num, -2, 1);
return \$ten;
}
/* Hundreds functions */
function hund(\$num){
\$hund    = substr(\$num, -3, 1);
return \$hund;
}
/* Thousands Function */
function thou(\$num){
\$thou    = substr(\$num, -4, 1);
return \$thou;
}
/* if it was 4 digits number */
if (\$leng == 4){
\$one = one(\$num);
\$ten = ten(\$num);
\$hund = hund(\$num);
\$thou = thou(\$num);
}
/* if it was 3 digits number */
if (\$leng == 3){
\$one = one(\$num);
\$ten = ten(\$num);
\$hund = hund(\$num);
}
/* if it was 2 digits number*/

if (\$leng == 2){
\$one = one(\$num);
\$ten = ten(\$num);
}
/* if it was 1 digit number */
if (\$leng == 1){
\$one = one(\$num);
}

/* ones */
if(isset(\$one)){
if(\$one == 1){
if(\$leng == 2){

if(\$ten == 1){
\$ones = \"eleven\";
}
else
{
\$ones = \"one\";
}

}else{
\$ones = \"one\";
}
}
if(\$one == 2){
if(\$leng == 2){
if(\$ten == 1){
\$ones = \"twelve\";
}
else
{
\$ones = \"two\";
}
}else{
\$ones = \"two\";
}
}
if(\$one == 3){
if(\$leng == 2){
if(\$ten == 1){
\$ones = \"thirteen\";
}
else
{
\$ones = \"three\";
}
}else{
\$ones = \"three\";
}
}
if(\$one == 4){
if(\$leng == 2){
if(\$ten == 1){
\$ones = \"fourteen\";
}
else
{
\$ones = \"four\";
}
}else{
\$ones = \"four\";
}
}
if(\$one == 5){
if(\$leng == 2){
if(\$ten == 1){
\$ones = \"fifteen\";
}
else
{
\$ones = \"five\";
}
}else{
\$ones = \"five\";
}
}
if(\$one == 6){
if(\$leng == 2){
if(\$ten == 1){
\$ones = \"sixteen\";
}
else
{
\$ones = \"six\";
}
}else{
\$ones = \"six\";
}
}
if(\$one == 7){
if(\$leng == 2){
if(\$ten == 1){
\$ones = \"seventeen\";
}
else
{
\$ones = \"seven\";
}
}else{
\$ones = \"seven\";
}
}
if(\$one == 8){
if(\$leng == 2){
if(\$ten == 1){
\$ones = \"eighteen\";
}
else
{
\$ones = \"eight\";
}
}else{
\$ones = \"eight\";
}
}
if(\$one == 9){
if(\$leng == 2){
if(\$ten == 1){
\$ones = \"nineteen\";
}
else
{
\$ones = \"nine\";
}
}else{
\$ones = \"nine\";
}
}
}

/* Tens */
if(isset(\$ten)){
if(\$num == 10){
\$tens = \"ten\";
}
if(\$ten == 2){
\$tens = \"twenty\";
}
if(\$ten == 3){
\$tens = \"thirty\";
}
if(\$ten == 4){
\$tens = \"fourty\";
}
if(\$ten == 5){
\$tens = \"fifty\";
}
if(\$ten == 6){
\$tens = \"sixty\";
}
if(\$ten == 7){
\$tens = \"seventy\";
}
if(\$ten == 8){
\$tens = \"eighty\";
}
if(\$ten == 9){
\$tens = \"ninty\";
}
}
/* Hundreds */
if(isset(\$hund)){
if(\$hund == 1){
\$hunds = \"one hundred\";
}
if(\$hund == 2){
\$hunds = \"two hundred\";
}
if(\$hund == 3){
\$hunds = \"three hundred\";
}
if(\$hund == 4){
\$hunds = \"four hundred\";
}
if(\$hund == 5){
\$hunds = \"five hundred\";
}
if(\$hund == 6){
\$hunds = \"six hundred\";
}
if(\$hund == 7){
\$hunds = \"seven hundred\";
}
if(\$hund == 8){
\$hunds = \"eight hundred\";
}
if(\$hund == 9){
\$hunds = \"nine hundred\";
}
}
/* Thousands */
if(isset(\$thou)){
if(\$thou == 1){
\$thous = \"one thousand\";
}
if(\$thou == 2){
\$thous = \"two thousand\";
}
if(\$thou == 3){
\$thous = \"three thousand\";
}
if(\$thou == 4){
\$thous = \"four thousand\";
}
if(\$thou == 5){
\$thous = \"five thousand\";
}
if(\$thou == 6){
\$thous = \"six thousand\";
}
if(\$thou == 7){
\$thous = \"seven thousand\";
}
if(\$thou == 8){
\$thous = \"eight thousand\";
}
if(\$thou == 9){
\$thous = \"nine thousand\";
}
}

echo \"<br />\";
/* print Thousands */
if(isset(\$thous)){
echo \$thous;
}

echo \" \";

/* Print Hundreds */
if(isset(\$hunds)){
echo \$hunds;
}

echo \" \";

/* print Tens */

if(isset(\$tens)){
if(\$ten != 1 and \$one == 0)
{
echo \$tens;

}
else
{
echo \$tens;
}

}

echo \" \";
/* Print Ones */
if(isset(\$ones)){
echo \$ones;
}

?>```

## Usage

Change \$num = 531; /* The Number */