$arr = array(2.1,3.1);
if(in_array(2.1000,$arr))
echo "yes";
else
echo "no";
I want it should show “No” but it ignores 0’s after decimal point.
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.
What you can do is
(string)$arr[0] == '2.1000'. The only problem is that when using a floating number in PHP it’s going to “remove” the leading and trailing zeros, therefore they are always going not to be zeros unless you store them as strings initially or if you keep track of the leading and trailing zeros in another array.