Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:11595 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33656 invoked by uid 1010); 28 Jul 2004 19:45:54 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 33629 invoked from network); 28 Jul 2004 19:45:54 -0000 Received: from unknown (HELO iko.gotobg.net) (80.168.8.116) by pb1.pair.com with SMTP; 28 Jul 2004 19:45:54 -0000 Received: from pd95e9fb1.dip.t-dialin.net ([217.94.159.177] helo=[192.168.0.32]) by iko.gotobg.net with asmtp (Exim 4.34) id 1BpuND-0008B3-8e for internals@lists.php.net; Wed, 28 Jul 2004 22:45:59 +0300 Message-ID: <41081C8C.6080304@hristov.com> Date: Wed, 28 Jul 2004 21:37:16 +0000 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8a2) Gecko/20040627 X-Accept-Language: en-us, en MIME-Version: 1.0 To: internals@lists.php.net Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - iko.gotobg.net X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - hristov.com X-Source: X-Source-Args: X-Source-Dir: Subject: Type juggling....again From: php@hristov.com (Andrey Hristov) 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 : Expected result: ---------------- bool(false) Actual result: -------------- int(1) Comments are welcome. Thanks, andrey