FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » why does in_array return true
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: why does in_array return true [message #169872 is a reply to message #169869] Wed, 29 September 2010 01:46 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 9/28/2010 9:24 PM, heartmeat wrote:
> hello all
>
> I must be missing something obvious, but, given:
>
> var $haystack = array(0);
> var $needle = '0_50';
>
> why does:
>
> in_array($needle,$haystack) return true?
>
> (PHP Version 5.2.4-2ubuntu5.10)
>
> thanks.

Because 0 is an integer and 0_50 is a string. See

http://www.php.net/manual/en/language.types.type-juggling.php

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: PHP manual note
Next Topic: Out Of Memory with Memory_limit à -1
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 05:41:44 GMT 2024

Total time taken to generate the page: 0.04252 seconds