Bug #64095 [Nab->Opn]: in_array does not work correct
| From: | jahangiri dot hamid at gmail dot com | Date: | Tue, 29 Jan 2013 11:39:18 +0000 |
| Subject: | Bug #64095 [Nab->Opn]: in_array does not work correct | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-176326@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64095&edit=1
ID: 64095
User updated by: jahangiri dot hamid at gmail dot com
Reported by: jahangiri dot hamid at gmail dot com
Summary: in_array does not work correct
-Status: Not a bug
+Status: Open
Type: Bug
Package: *General Issues
Operating System: win 7
PHP Version: 5.3Git-2013-01-29 (Git)
Block user comment: N
Private report: N
New Comment:
i found that this problem is just for index 0 or better to say for forst cell of
array it work nice woth other so i add a null value for first cell og array and i
solve it
Previous Comments:
------------------------------------------------------------------------
[2013-01-29 11:37:31] cataphract@php.net
in_array() looks for values, not keys; see key_exists()
------------------------------------------------------------------------
[2013-01-29 11:30:23] jahangiri dot hamid at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.in-array#refsect1-function.in-array-
returnvalues
---
in_array doesnot work properly
Test script:
---------------
my array : array is result of print_r of my real array
$arrayvar = Array ( [0] => 90 [1] => a [2] => [3] => 1 [4] => b [5] => [6]
=> 2 [7] => c [8] => [9] => 4 [10] => d [11] => [12] => 6 [13] => e [14]
=> [15] => 7 [16] => f [17] => [18] => 8 [19] => g [20] => [21] => 9 [22]
=> h [23] => [24] => 10 [25] => i [26] => [27] => 11 [28] => j [29] => [30]
=> 12 [31] => k [32] => [33] => 14 [34] => l [35] => [36] => 100 [37] => m
[38] => )
my needle : $key=90;
my code :
in_array($key,$arrayvar);
it return false
Expected result:
----------------
true
Actual result:
--------------
false
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64095&edit=1