example:
the following is correct?
$var = floatval($arr[2]) ;
“You cannot use floatval() on arrays…” maybe that’s an old directive or how to edit…?
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.
That quote from the manual (which BTW doesn’t seem to exist in the current manual anymore) only means that you can’t use
floatvalon values that are arrays, i.e.:Which, BTW, is not entirely correct, since it would produce either
1.0or0.0, depending on whether the array was empty or not.* It just doesn’t make much sense. If you access a scalar value inside an array, that’s not using “floatvalon an array”. I.e., this works perfectly fine:That’s using the scalar value in
$foo[0], whether that’s in an array or not is irrelevant.* The manual now clearly says
Empty arrays return 0, non-empty arrays return 1.Maybe this behavior has changed?