note 85544 added to function.in-array
| From: | raven990862atgm at toast dot fresh dot co dot il | Date: | Fri, 05 Sep 2008 02:27:02 +0000 |
| Subject: | note 85544 added to function.in-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-144149@lists.php.net to get a copy of this message | ||
Quick note:
<?php
$a = array('999999999999999999');
if(in_array('999999999999999990',$a))
{
echo "true";
}
?>
prints a true to the screen
---
<?php
$a = array('999999999999999999');
if(in_array('999999999999999990',$a,true))
{
echo "true";
}
?>
does not print anything
Some would call this a bug, Some would not...
What I think is happening is in_array is converting the strings to floats and truncating the least
significant part of the value.
----
Server IP: 208.69.120.35
Probable Submitter: 98.198.54.101
----
Manual Page -- http://www.php.net/manual/en/function.in-array.php
Edit -- https://master.php.net/note/edit/85544
Del: integrated -- https://master.php.net/note/delete/85544/integrated
Del: useless -- https://master.php.net/note/delete/85544/useless
Del: bad code -- https://master.php.net/note/delete/85544/bad+code
Del: spam -- https://master.php.net/note/delete/85544/spam
Del: non-english -- https://master.php.net/note/delete/85544/non-english
Del: in docs -- https://master.php.net/note/delete/85544/in+docs
Del: other reasons-- https://master.php.net/note/delete/85544
Reject -- https://master.php.net/note/reject/85544
Search -- https://master.php.net/manage/user-notes.php