var $number = 1234
var $thousands = 1
var $hundreds = 2
var $tens = 3
var $ones = 4
switch ($thousands)
{
case: 1: $thousandstring = "One thousand "; break;
case: 2: $thousandstring = "Two thousand "; break;
case: 3: $thousandstring = "Three thousand "; break;
// etc
}
switch ($hundreds)
{
case: 1: $hundredsstring = "One hundred "; break;
case: 2: $hundredsstring = "Two hundred "; break;
// etc
}
// do the same for the tens and ones
// finally, concat the four strings you got:
$result = $thousandstring + $hundredsstring + $tensstring + $onesstring;