ID:               27677
 User updated by:  rattray at purdue dot edu
 Reported By:      rattray at purdue dot edu
-Status:           Bogus
+Status:           Open
 Bug Type:         *Programming Data Structures
 Operating System: windows and unix
 PHP Version:      4.3.4
 New Comment:

If this is not a bug, then why does the code work as I expected it to
in PHP 5.0.0RC1?


Previous Comments:
------------------------------------------------------------------------

[2004-03-25 15:50:15] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The string key when accessing a portion of another string 

is converted to an integer. Because it is a string it gets 

converted to 0, so you end up accessing the 1st letter of 

the 1st word. 

------------------------------------------------------------------------

[2004-03-24 13:39:10] rattray at purdue dot edu

Description:
------------
using isset() to detect the existence of array subkeys give a false
positive.  Also, trying to print the content of said non-existing keys
gives the first character of the parent key!

Reproduce code:
---------------
$aArray = array();

$aArray["key"] = "value";

print("<PRE>".print_r($aArray, true)."</PRE>");

if (isset($aArray))

        print("Array exists<BR>");

else print("Array does not exist.<BR>");

if (isset($aArray["key"]))

        print("Array[key] exists, value = '".$aArray["key"]."'<BR>");

else print("Array[key] does not exist.<BR>");

if (isset($aArray["key"]["subkey"]))

        print("Array[key][subkey] exists, value =
'".$aArray["key"]["subkey"]."'<BR>");

else print("Array[key][subkey] does not exist.<BR>");



Expected result:
----------------
Array

(

    [key] => value

)



Array exists

Array[key] exists, value = 'value'

Array[key][subkey] does not exist

Actual result:
--------------
Array

(

    [key] => value

)



Array exists

Array[key] exists, value = 'value'

Array[key][subkey] exists, value = 'v'


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=27677&edit=1

Reply via email to