#23626 [NEW]: in_array and array_search stop at value 0
From: jjkola at email dot com
Operating system: Win2000
PHP version: 4CVS-2003-05-14 (stable)
PHP Bug Type: Arrays related
Bug description: in_array and array_search stop at value 0
Hi!
I think I found a bug. I had a array where one of the values were zero and
I tried to search with in_array and later also with array_search if there
is a string for example "-". I expected them to tell me if the string is
in array, but the result was always same wether or not there was searched
string and it was that they gave me answer true when checking with
in_array and when checking with array_search it gave me location of that
zero value. Here is a sample code snippet the fiddle with:
<?php
$test=array(0,"*",1,"+",2);
if (in_array("-",$test)) print"string bug!\n";
if (in_array("abc",$test)) print"string bug!\n";
$test=array(1,"*",0,"+",2);
if (array_search("-",$test)) {
print "string buugie!\n";
$value=array_search("-",$test);
print "Value is $value.";
}
?>
I tried it with longer strings and it behaved same way as told above. I
checked also with other types of variables as a needle but they worked
fine.
--
Edit bug report at http://bugs.php.net/?id=23626&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=23626&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=23626&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=23626&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=23626&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=23626&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=23626&r=support
Expected behavior: http://bugs.php.net/fix.php?id=23626&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=23626&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=23626&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=23626&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23626&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=23626&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=23626&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=23626&r=gnused
Thread (7 messages)
- jjkola at email dot com