|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-02-02 14:19 UTC] peehaa@php.net
[2018-02-02 14:28 UTC] peehaa@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: peehaa
[2018-02-02 14:28 UTC] peehaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 14 21:00:01 2025 UTC |
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 )