Bug #73731 [Opn->Nab]: in_array does not find NAN value

From: Date: Tue, 13 Dec 2016 10:15:44 +0000
Subject: Bug #73731 [Opn->Nab]: in_array does not find NAN value
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-205952@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73731&edit=1 ID: 73731 Updated by: cmb@php.net Reported by: desinformatsioon at gmail dot com Summary: in_array does not find NAN value -Status: Open +Status: Not a bug Type: Bug Package: Arrays related Operating System: Ubuntu 16.04 PHP Version: 7.0.14 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php NAN is never equal to itself, see <http://php.net/manual/en/language.types.float.php#language.types.float.nan>. Previous Comments: ------------------------------------------------------------------------ [2016-12-13 09:56:08] desinformatsioon at gmail dot com Description: ------------ Currently in_array(NAN, [0,NAN, null]) results with false but I would expect true would be proper as NAN is indeed in haystack. Test script: --------------- <?PHP echo "in_array(0, [0,NAN, null]) should result true" . PHP_EOL; var_dump(in_array(0, [0,NAN, null])); echo "in_array(null, [0,NAN, null]) should result true" . PHP_EOL; var_dump(in_array(null, [0,NAN, null])); echo "in_array(NAN, [0,NAN, null]) should result true but result false" . PHP_EOL; var_dump(in_array(NAN, [0,NAN, null])); Actual result: -------------- xxxx:~/code/$ php x.php in_array(0, [0,NAN, null]) should result true xxxx/x.php:4: bool(true) in_array(null, [0,NAN, null]) should result true xxxx/x.php:7: bool(true) in_array(NAN, [0,NAN, null]) should result true but result false xxxx/x.php:10: bool(false) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=73731&edit=1

« previous php.bugs (#205952) next »