Code:
var_dump($prodCost);
$prodCost = (float)$prodCost;
var_dump($prodCost);
result:
string(5) “$4.57”
float(0)
What am I doing wrong here? I am looking for the result to be float(4.57).
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.
The $-sign is not valid for numbers, PHP will break off after the first non-numeric char. Try this: