I have been working on this code for hours and I cant seem to make it work. I have an input field that allows users to submit a price for a certain item. Here is the desired process:
//Get the post it price and only allow numbers and one period|dot
$price = $_POST['price'];
$price = preg_replace('#[^0-9.]#i', '', $_POST['price']);
So I only want to allow one period per string, so if the User inputs 100.00.00, it will correct that and remove the first period and convert it to 10000.00
After this I want to add a comma for every 3rd character as follows:
if the posted price is 10000.00 it will convert it to 10,000.00.
Is there any way to accomplish this?
http://codepad.viper-7.com/t1WuGK