php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48183 access to associative array element by key
Submitted: 2009-05-07 16:36 UTC Modified: 2009-05-12 12:37 UTC
From: foolged at inbox dot ru Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.2.9 OS: windows xp sp3
Private report: No CVE-ID: None
 [2009-05-07 16:36 UTC] foolged at inbox dot ru
Description:
------------
$a = array ('id'=>'abc');
if (isset($a['id']['BUG']))
  echo 'BUG!!!!!!!!';
 
$a = array ('id'=>'abc');
echo $a['id']['BUG']." <-BUGGGGG!!!!!!";  


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-07 16:59 UTC] lbarnaud@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 [2009-05-12 12:37 UTC] foolged at inbox dot ru
I understand that you want to say that this is a consequence of recourse to the string as to the array:
$ a = array ( 'id' => 'zxy');
echo $ a [ 'id'] [1]; // x

But such behavior should be when using a numeric key,
in the case of associative keys should be an error (an element with key 'BUG' not found).
PHP cast string 'BUG' to int 0 and returns $a['id'][0], it is logical to you?
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Dec 14 20:01:23 2019 UTC