I would like to work with numbers like 10M (which represents 10 000 000), and 100K etc. Is there a function that already exists in PHP, or do I have to write my own function?
I’m thinking something along the lines of :
echo strtonum("100K"); // prints 100000
Also, taking it one step further and doing the opposite, something to translate and get 100K from 100000?
You could whip up your own function, because there isn’t an builtin function for this. To give you an idea:
Demo: http://codepad.viper-7.com/2rxbP8
Or the other way around:
Demo: http://codepad.viper-7.com/VeRGDs
If you want to get really funky you could put all that in a class and let it decide what conversion to run:
Although this may be a bit overkill 🙂
Demo: http://codepad.viper-7.com/KZEc7b