Bug #70798 [Opn->Nab]: array_search - positive match on $haystack[0] evalutes to boolean FALSE

From: Date: Tue, 27 Oct 2015 01:24:31 +0000
Subject: Bug #70798 [Opn->Nab]: array_search - positive match on $haystack[0] evalutes to boolean FALSE
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196834@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70798&edit=1 ID: 70798 Updated by: requinix@php.net Reported by: andreas dot baumgaertner at tisco dot at Summary: array_search - positive match on $haystack[0] evalutes to boolean FALSE -Status: Open +Status: Not a bug Type: Bug Package: *General Issues Operating System: Windows Server 2012 R2 PHP Version: 5.6.14 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php http://php.net/manual/en/function.array-search.php > Warning: This function may return Boolean FALSE, but may also return a non- > Boolean value which evaluates to FALSE. Please read the section on Booleans for > more information. Use the === operator for testing the return value of this > function. Previous Comments: ------------------------------------------------------------------------ [2015-10-27 01:03:52] andreas dot baumgaertner at tisco dot at Description: ------------ array_search - positive match on $haystack[0] evalutes to boolean FALSE the same value at integer array index 1 matches perfectly and evaluates to 1 -- change sample script to $haystack[1] = 'German'; $haystack[2] = 'English'; array_search('german',$haystack_lower) returns 1 now ... Test script: --------------- <?php $haystack = array(); $haystack[0] = 'German'; $haystack[1] = 'English'; $haystack_lower = array_map('strtolower', $haystack); print_r($haystack); print_r('<br>'); print_r($haystack_lower); print_r('<br>'); if (array_search('german',$haystack_lower) != FALSE) { print_r('match'); } ?> ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70798&edit=1

« previous php.bugs (#196834) next »