note 114402 deleted from language.oop5.properties by nikic

From: Date: Tue, 27 Sep 2016 13:56:21 +0000
Subject: note 114402 deleted from language.oop5.properties by nikic
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-206683@lists.php.net to get a copy of this message
Note Submitter: Ashley Dambra ---- Updated method objectThis() to transtypage class array properties or array to stdClass. Hope it help you. public function objectThis($array = null) { if (!$array) { foreach ($this as $property_name => $property_values) { if (is_array($property_values) && !empty($property_values)) { $this->{$property_name} = $this->objectThis($property_values); } else if (is_array($property_values) && empty($property_values)) { $this->{$property_name} = new stdClass(); } } } else { $object = new stdClass(); foreach ($array as $index => $values) { if (is_array($values) && empty($values)) { $object->{$index} = new stdClass(); } else if (is_array($values)) { $object->{$index} = $this->objectThis($values); } else { $object->{$index} = $values; } } return $object; } }

« previous php.notes (#206683) next »