A problem about in_array

Posted by SpawnCxy on Stack Overflow See other posts from Stack Overflow or by SpawnCxy
Published on 2010-03-19T11:42:42Z Indexed on 2010/03/19 11:51 UTC
Read the original article Hit count: 368

Filed under:
|

Hi all,

I have got a strange problem about in_array recently which I cannot understand. e.g.

$a = array('a','b','c');
$b = array(1,2,3);

if (in_array(0,$a))
{
    echo "a bingo!\n";
}
else
{
    echo "a miss!\n";
}

if (in_array(0,$b))
{
    echo "b bingo!\n";
}
else
{
    echo "b miss!\n";
}

I ran it on my lamp,and got

a bingo!
b miss!

I read the manual and set the third parament $strict as true,then it worked as expected.But does that mean I always need to set the strict parament as true when using in_array?Suggestions would be appreciated.

Regards

© Stack Overflow or respective owner

Related posts about php

Related posts about array