ID: 37742
User updated by: eric dot daspet at survol dot net
Reported By: eric dot daspet at survol dot net
Status: Open
Bug Type: SPL related
Operating System: MS Windows XP
PHP Version: 5.1.4
New Comment:
Well, sorry, I have put Actual Result and Expected result in the wrong
order.
Previous Comments:
------------------------------------------------------------------------
[2006-06-08 12:45:28] eric dot daspet at survol dot net
Description:
------------
When a multidimentional superglobal is used to feed ArrayObjet, the
first unset of a sub-index is ignored.
- it is ok with a "normal" array, I've seen this only with $_REQUEST
and $_GET
- it is ok with $_GET as a simple array (one dimension)
- the second call to unset() succeed, either if is the exact same call
or if I try to unset another index, only the first fails
Reproduce code:
---------------
<?php
// call the script with ?index[i]=1&index[j]=2
$ao = new ArrayObject( $_GET ) ;
unset( $ao['index']['i'] ) ; // ignored
var_dump($ao) ;
unset( $ao['index']['j'] ) ; // ok
var_dump($ao) ;
unset( $ao['index']['i'] ) ; // ok
var_dump($ao) ;
Expected result:
----------------
object(ArrayObject)#1 (1) {
["index"]=> array(2) {
["i"]=> string(1) "1"
["j"]=> string(1) "2"
}
}
object(ArrayObject)#1 (1) {
["index"]=> array(1) {
["i"]=> string(1) "1"
}
}
object(ArrayObject)#1 (1) {
["index"]=> array(0) {
}
}
Actual result:
--------------
object(ArrayObject)#1 (1) {
["index"]=> array(1) {
["j"]=> string(1) "1"
}
}
object(ArrayObject)#1 (1) {
["index"]=> array(0) {
}
}
object(ArrayObject)#1 (1) {
["index"]=> array(0) {
}
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37742&edit=1