|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-07-26 22:09 UTC] simon+php at thulbourn dot com
Description:
------------
An array with no associative keys doesn't throw a notice or error when
one is used as an associative keyed array.
Reproduce code:
---------------
<?php
$array = array('foo', 'bar', 'baz');
foreach ($array as $a) {
echo $a['foo'];
}
?>
Expected result:
----------------
Notice: Undefined index
Actual result:
--------------
fbb
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 21 21:00:01 2025 UTC |
Granted, I could have provided a better sample case so: $a = array('foo'); // echo a index that doesn't exist echo $a['bar']; PHP should produce a notice claiming an undefined index 'bar', instead it outputs the first char of the 0 index, in this case 'f', it's obviously converting the string to a 0 instead of producing the notice.)