hi,
Long back one of my friend was facing the same pblm but it was in java.
I gave her the code which would generate the figure up to 9,99,999.
The idea is as follows
built a array with one two three ...nine and
ten,twenty,.....ninenty..
Use this arrays to find your number
but its not so easy needs lot of patience
first derive from a larger number then you can optimize the code.
I hope u can get the rest..but u can find help from some one if there are any built-in-functions in PHP.
Good Luck
s.r.k.reddy