Req #75908 [Opn->Csd]: unset do not work
| From: | peehaa@php.net | Date: | Fri, 02 Feb 2018 14:28:07 +0000 |
| Subject: | Req #75908 [Opn->Csd]: unset do not work | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-213786@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75908&edit=1
ID: 75908
Updated by: peehaa@php.net
Reported by: novoyura2 at gmail dot com
Summary: unset do not work
-Status: Open
+Status: Closed
Type: Feature/Change Request
Package: Arrays related
Operating System: ubuntu
PHP Version: 5.6.33
-Assigned To:
+Assigned To: peehaa
Block user comment: N
Private report: N
New Comment:
This specifically targeted 7.2:
https://wiki.php.net/rfc/convert_numeric_keys_in_object_array_casts
Previous Comments:
------------------------------------------------------------------------
[2018-02-02 14:19:19] peehaa@php.net
This has already been fixed in 7.2.0.
https://3v4l.org/eDiXa
Might also need to be fixed in 7.1 as that is still supported?
------------------------------------------------------------------------
[2018-02-02 14:05:17] novoyura2 at gmail dot com
Description:
------------
Cant get element by key after transform object to array
Test script:
---------------
$a = [0 => 1, 1=>3, 2=> 6];
print_r($a);
$o = new stdClass();
foreach($a as $key => $value){
$o->$key = $value;
}
$a = (array)$o;
print_r($a);
foreach ($a as $key => $id) {
unset($a[$key]);
}
print_r($a);
Expected result:
----------------
Array ( [0] => 1 [1] => 3 [2] => 6 ) Array ( [0] => 1 [1] => 3 [2] => 6 ) Array()
Actual result:
--------------
Array ( [0] => 1 [1] => 3 [2] => 6 ) Array ( [0] => 1 [1] => 3 [2] => 6 ) Array (
[0] => 1 [1] => 3 [2] => 6 )
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75908&edit=1