How to Convert number from digits to words into two languages English language and Marathi language
Is it possible using php?

Can anybody help me?

If I understand the question correctly you would like to suplement numbers with words in two languages. I would do that with arrays. If the range of numbers is not too big you can map numbers to words directly:

$englishWords = array(
    1 => 'one',
    2 => 'two',
    3 => 'three',
    1 => 'four',
    5 => 'five',

$marathiWords = array(
    1 => 'one in marathi',
    2 => 'two in marathi',
    3 => 'three in marathi',

echo '2 is ' . $englishWords[2] . ' in english and ' . $marathiWords[2] . ' in marathi.';

Depending on how you intend to use the numbers they could be also in one two-dimensional array:

// using italian in this example since I do not speak marathi :-)
$number2words = array(
    1 => array('english' => 'one', 'italian' => 'uno'),
    2 => array('english' => 'two', 'italian' => 'due'),
    3 => array('english' => 'three', 'italian' => 'tre'),

echo '2 is ' . $number2words[2]['english'] . ' in english and ' . $number2words[2]['italian'] . ' in italian.';

If you have a big range of numbers then you have to make up some more clever logic to display numbers with words (like interpreting hundreds, thousand etc).

Member Avatar

This can be more complicated in non-English languages. Most languages have distinct names for 0-20, and mutiples of 10 up to 100 - some of which seem to be multiples of others, e.g. 80 in French = "quatre-vingts". Then distincts for the occasional power of 10: (100, 1000, 1000000 ...)

Some, like Italian contract when two consecutive vowels come into contact, e.g.

21: ventuno (venti + uno)
38: trentotto (trenta + otto)

A further complication can arise if using gender forms for certain objects, e.g. Welsh

2: dau, dwy
3: tri, tair

These issues tend not to arise in English, but sometimes you need to insert things like "and", e.g. one hundred "and" one; two thousand "and" forty-six.

Marathi from what I can gather has a similar pattern to most others?

Perhaps the best approach would be to create a 'rules' array or 'combination' array for each language too.

commented: Impressive (the knowledge about languages) +7

So, I have to write each number into word in array , am I right?

Is there any function in php to convert number into word automatically?

@Bachov Varghese


Trying for marathi.