So i have some fields coming from the form. Here you can type 0.3 and it will insert 0.3 in to the database. Do you type 0,3 it will just insert “0”.
$product['protein']; // 0,3
So to this above how can i replace a comma with a dot ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try PHP’s function str_replace():
Which should be a good fit.
You could think to use number_format():
but in your case it wouldn’t apply, due to the fact that your starting value (“0,3”) wouldn’t be recognized as a number.
In fact, the decimal point for a numeric value must be a dot(“.”).
Use number_format only if your starting value is a true number.