php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #44016 Key function documentation implies it only works for associative arrays
Submitted: 2008-02-01 21:50 UTC Modified: 2008-02-04 18:14 UTC
From: cythrawll at codeangel dot org Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2008-02-01 21:50 UTC] cythrawll at codeangel dot org
Description:
------------
Documentation for key() function suggests it works only for associative arrays, however it works for both numerical and associative.

PHP Manual for key() function states for the short description:

key ? Fetch a key from an associative array

Reproduce code:
---------------
<?php

$arr = array("test", "test2");
reset($arr);
echo key($arr);
next($arr);
echo key($arr);

?>

Expected result:
----------------
key ? Fetch a key from an array

Actual result:
--------------
key ? Fetch a key from an associative array

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-02 22:11 UTC] cythrawll at codeangel dot org
fixed spelling
 [2008-02-04 18:14 UTC] philip@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 12:00:02 2026 UTC