php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #64453 array_key_exists function
Submitted: 2013-03-19 06:52 UTC Modified: 2013-03-21 16:25 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: billsion at gmail dot com Assigned: ab (profile)
Status: Closed Package: Online Doc Editor problem
PHP Version: 5.3.23 OS: Windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: billsion at gmail dot com
New email:
PHP Version: OS:

 

 [2013-03-19 06:52 UTC] billsion at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.array-key-exists#refsect1-function.array-key-exists-description
---


array_key_exists function accept two parameters, the first one is "Mixed" which is tell in the documentation, but it gives a warning : 'it must be string or integer'. there should not display any warning even I set the error_reporting is "E_ALL | E_STRICT".

Test script:
---------------
<?php
$key = array('trade_mode', 'trade_state');

$params['trade_mode'] = 1;
$params['trade_state'] = 1;
$params['a'] = 1;
$params['b'] = 1;

if(array_key_exists($key, $params)){
	echo 1;
}else{
	echo 2;
}
exit;

Expected result:
----------------
1

Actual result:
--------------
Warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in D:\www\index.php on line 9
2

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-03-21 16:25 UTC] ab@php.net
IMHO you get it wrong, if I read that doc page:

array_key_exists() returns TRUE if the given key is set in the array. key can be any value possible for an array index. 

and also:

mixed indicates that a parameter may accept multiple (but not necessarily all) types. 

Possible for key are int|string which is also what mixed means.
 [2013-03-21 16:25 UTC] ab@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: ab
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 10:01:38 2025 UTC