# Type juggling....again

- Thread: https://externals.io/message/11595
- Original archive: https://news-web.php.net/php.internals/11595
- Started by Andrey Hristov on 2004-07-28T21:37:16+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #11595 — Andrey Hristov — 2004-07-28T21:37:16+00:00

URL: https://externals.io/message/11595#11595

Hello internals,
in the bug system there is an entry # 29421:
(http://bugs.php.net/bug.php?id=29421)
In short. `in_array()` and `array_search()` return the first
boolean(true) when the user looks for an element that
evaluates to true according to PHP's type juggling.
The opposite is also valid and can be very neat : one
can realize whether there are non-zero (evaluating to zero)
elements in a array with the following :
$array=array(0,0,1,0,0);var_dump(in_array(true, $array));

The example for the report :
<?php
$array = array ( 'foo' , `TRUE` , 'bar' ) ;
var_dump (array_search ( 'baz' , $array ) ) ;
?>
Expected result:
----------------
bool(false)

Actual result:
--------------
int(1)

Comments are welcome.

Thanks,
andrey
