Reputation: 57
I have a number as 10,000
in my post data, and I want to store in db as 10000.00
I currently have the following: (in Kohana)
number_format(input::post('amount'),2,'.','');
but this gives me the error:
ErrorException [ Notice ]: A non well formed numeric value encountered
Since $_POST['amount']
= 10,000
Any suggestions how can I solve this?
Upvotes: 2
Views: 792
Reputation: 7673
The comma is causing the problem, you could strip it out using str_replace
number_format(str_replace(',', '', input::post('amount')), 2, '.', '');
Upvotes: 2