note 114401 added to language.oop5.properties
| From: | AshleyDambra | Date: | Sun, 16 Feb 2014 10:29:16 +0000 |
| Subject: | note 114401 added to language.oop5.properties | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-198526@lists.php.net to get a copy of this message | ||
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;
}
}
----
Server IP: 72.52.91.14
Probable Submitter: 72.52.91.14
----
Manual Page -- http://php.net/manual/en/language.oop5.properties.php
Edit -- https://master.php.net/note/edit/114401
Del: integrated -- https://master.php.net/note/delete/114401/integrated
Del: useless -- https://master.php.net/note/delete/114401/useless
Del: bad code -- https://master.php.net/note/delete/114401/bad+code
Del: spam -- https://master.php.net/note/delete/114401/spam
Del: non-english -- https://master.php.net/note/delete/114401/non-english
Del: in docs -- https://master.php.net/note/delete/114401/in+docs
Del: other reasons-- https://master.php.net/note/delete/114401
Reject -- https://master.php.net/note/reject/114401
Search -- https://master.php.net/manage/user-notes.php