Req #75908 [Opn]: unset do not work

From: Date: Fri, 02 Feb 2018 14:19:19 +0000
Subject: Req #75908 [Opn]: unset do not work
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213784@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 Type: Feature/Change Request Package: Arrays related Operating System: ubuntu PHP Version: 5.6.33 Block user comment: N Private report: N New Comment: 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? Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#213784) next »