Re: Strange array access problem

From: Date: Wed, 26 Oct 2005 05:34:54 +0000
Subject: Re: Strange array access problem
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-224666@lists.php.net to get a copy of this message
Rob , Very helpful, Thanks! I'll try to rewrite the serializer on the javascript end to encode integer keys as integers. Ken On Oct 26, 2005, at 1:23 AM, Robert Cummings wrote:
On Wed, 2005-10-26 at 01:06, Robert Cummings wrote:
I did some more investigating. Your problem appears to be PHP5 specific. I manually created the serialize string I assumed you had, but PHP4 was smarter than me and auto converted the string key to an integer once again; however, PHP5 for some reason during unserialization maintained the string type for the key, however it was not able to access the value because upon attempting to access the value I'm assuming it did a type conversion to integer... additionally I got the following error notice when trying to access the value: <b>Notice</b>: Undefined index: 0 in <b>/home/suds/foo.php</b> on line <b>25</b><br /> NULL The following can duplicated the error: $ser = 'a:1:{s:1:"0";s:3:"foo";}'; $unser = unserialize( $ser ); var_dump( $unser ); var_dump( $unser['0'] );
FYI this is not considered a bug in PHP since PHP will not produce serialized output in that form (IMHO it is a bug since it deviates from an expected functionality with respect to how serialized data should be encoded-- but then maybe there's a doc somewhere that states you have to convert integer strings to real integers for keys *shrug*):
    http://bugs.php.net/bug.php?id=27712
Cheers, Rob. --.------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------' --PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.general (#224666) next »