Apart from Marek's reply, you should probably check the in_array()
documentation (look at the third, optional parameter) and search for
type casting on php.net.
Cheers,
Bogdan
Ing. Ivo F.A.C. Fokkema wrote:
Hi guys and gals,
I'm not screaming "Bug! Bug!" but this _does_ look 'illogical' to me. I've
searched the archives, but found no earlier conversation. Sorry if
I missed it. Consider the following code:
var_dump(in_array('test', array(0)));
What does this return? I expect bool(false), but it returns bool(true).
After some searching the web, I bumped into this:
http://www.phpdiscuss.com/article.php?id=67763&group=php.bugs
Basically, it is said by derick [at] php.net that this behavior is
expected. The following code :
var_dump('test' == 0);
also returns bool(true). But my logic tells me, that if 'test' == 0, then :
if (0) {
...
}
should do the same as
if ('test') {
...
}
but it doesn't! The first if-statement is _not_ executed, the latter is.
In my opinion, this is not correct. Any thoughts on this? Am I not seeing
the logic here?
Thanks for your thoughts.
Ivo Fokkema
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php