|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63736 array_key_exists extremely slow on referenced arrays
Submitted: 2012-12-10 13:39 UTC Modified: 2012-12-10 14:43 UTC
From: ymgve dot aa at gmail dot com Assigned:
Status: Not a bug Package: Performance problem
PHP Version: 5.4.9 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
41 - 7 = ?
Subscribe to this entry?

 [2012-12-10 13:39 UTC] ymgve dot aa at gmail dot com
When you use array_key_exists() on a referenced array, it performs extremely slow compared to isset():

isset time 0.0053699016571045 size 0
isset time 0.0051219463348389 size 10
isset time 0.0032069683074951 size 100
isset time 0.0034000873565674 size 1000
isset time 0.0052909851074219 size 10000
array_key_exists time 0.0055620670318604 size 0
array_key_exists time 0.010941982269287 size 10
array_key_exists time 0.048230886459351 size 100
array_key_exists time 0.38906383514404 size 1000
array_key_exists time 5.6351599693298 size 10000

Due to the time increasing near linearly with the number of elements in the array, I assume the code for some reason looks through the array key linearly instead of using a hash lookup.

Test script:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-12-10 14:43 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

References disable copy-on-write. has some details
 [2012-12-10 14:43 UTC]
-Status: Open +Status: Not a bug
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 24 23:01:31 2024 UTC