Edit report at https://bugs.php.net/bug.php?id=65639&edit=1
ID: 65639 Updated by: requi...@php.net Reported by: sv3tli0 at bgspot dot eu Summary: in_array unexpected result -Status: Open +Status: Not a bug Type: Bug Package: Arrays related Operating System: Ubuntu 13.04 PHP Version: 5.4.19 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 in_array() does a loose comparison by default, and 0 == 'some string not INT'. If you need a strict comparison then pass true for the third argument. http://www.php.net/in-array Previous Comments: ------------------------------------------------------------------------ [2013-09-09 07:35:53] sv3tli0 at bgspot dot eu Description: ------------ Wrong result if you are checking array for existing integer 0, when array has none integer values.. Test script: --------------- $array = array(1,2,3); var_dump(in_array(0, $array)); $array = array(1,2,'some string not INT'); var_dump(in_array(0, $array)); Expected result: ---------------- boolean false boolean false Actual result: -------------- boolean false boolean true ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=65639&edit=1