|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-12-23 23:35 UTC] ajf@php.net
[2016-02-02 05:32 UTC] sagar at aspl dot in
[2016-08-08 12:13 UTC] cmb@php.net
-Status: Open
+Status: Duplicate
-Assigned To:
+Assigned To: cmb
[2016-08-08 12:13 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 05:00:01 2025 UTC |
Description: ------------ Converting a stdClass object with (array) behaves different than get_object_vars() I tested this with PHP 5.4.45 5.5.18 and 5.6.2 Test script: --------------- $tmp = json_decode(json_encode( (object) array('cars' => (object) array("1" => "one")) )); // expected $cars = array("1" => "one"); $cars = (array) $tmp->cars; var_dump(array_key_exists("1", $cars)); // expected true, returns false var_dump(array_key_exists(1, $cars)); // expected true, returns false $cars = get_object_vars($tmp->cars); var_dump(array_key_exists("1", $cars)); // expected true, returns true var_dump(array_key_exists(1, $cars)); // expected true, returns true