Why does in_array() wrongly return true with these (large numeric) strings?

后端 未结 9 2146
夕颜
夕颜 2020-12-08 00:35

I am not getting what is wrong with this code. It\'s returning \"Found\", which it should not.

$lead = \"418176000000069007\";
$diff = array(\"41817600000006         


        
9条回答
  •  粉色の甜心
    2020-12-08 01:18

    It's because of one defect in PHP. 418176000000069007 is modified to 2147483647 (integer limit of PHP). That is why you are getting Found.

    try in_array($lead, $diff, true)

    If the third parameter strict is set to TRUE then the in_array() 
    function will also check the types of the needle in the haystack. 
    

提交回复
热议问题