php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43733 array_keys returns keys from sub arrays in multi-dimensional array
Submitted: 2008-01-03 01:05 UTC Modified: 2008-01-04 19:48 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: lakinekaki at gmail dot com Assigned:
Status: Closed Package: Arrays related
PHP Version: 4.4.7 OS: Linux
Private report: No CVE-ID: None
 [2008-01-03 01:05 UTC] lakinekaki at gmail dot com
Description:
------------
http://us2.php.net/function.array-keys

when compared with result c from example on above page, it seems that what i get is not expected result. array-keys function tests against all keys in all sub arrays!

Reproduce code:
---------------
<?php
//example array of simple website navigation structure

$array = array("about.php","contact.php","projects.php" => array("project_1.php" => array("project_1a.php","project_1b.php"),"project_2.php"));

if(in_array('project_1.php',array_keys($array)))echo 'not working as expected';
?>


Expected result:
----------------
I expect no output, but see 'not working as expected' 


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-04 19:48 UTC] lakinekaki at gmail dot com
I am devoid of reading comprehension. The very first line in the manual said that function returns all array keys. However, example was little confusing and led me to believe the opposite.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 07 04:01:30 2024 UTC