Re: Strange array access problem

From: Date: Wed, 26 Oct 2005 05:23:55 +0000
Subject: Re: Strange array access problem
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-224665@lists.php.net to get a copy of this message
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. | `------------------------------------------------------------'

« previous php.general (#224665) next »