convert number to words in php

Converting words to numbers in PHP

Welcome back to shorltearner.com, we are starting a new series of PHP interview questions for beginners and experienced,so in previous post we learn, Write a PHP program to check if the bits of the two given positions of a number are same or not
In this post we see how to Converting words to numbers in PHP.
Also Read
Unable to create a directory a wordpress error
PHP program that multiplies corresponding elements of two given lists
PHP program to print out the multiplication table up to 6*6

convert number to words in php
<?php
function word_digit($word) {
    $warr = explode(';',$word);
    $result = '';
    foreach($warr as $value){
        switch(trim($value)){
            case 'zero':
                $result .= '0';
                break;
            case 'one':
                $result .= '1';
                break;
            case 'two':
                $result .= '2';
                break;
            case 'three':
                $result .= '3';
                break;
            case 'four':
                $result .= '4';
                break;
            case 'five':
                $result .= '5';
                break;
            case 'six':
                $result .= '6';
                break;
            case 'seven':
                $result .= '7';
                break;
            case 'eight':
                $result .= '8';
                break;
            case 'nine':
                $result .= '9';
                break;    
        }
    }
    return $result;
}

echo word_digit("zero;three;five;six;eight;one")."\n";
echo word_digit("seven;zero;one")."\n";
?>
035681 701