Posted by BuzzClifton on 10/23/31 11:40
Something like this, maybe?
function &array_to_object(&$ra, $class
= 'stdclass')
{
if (!is_array($ra)) trigger_error("not an
array", E_USER_ERROR);
if (!class_exists($class))
trigger_error("not a class", E_USER_ERROR);
$result = &new $class;
foreach (array_keys($ra) as $k) {
if (is_array($ra[$k])) {
$result->$k = array_to_object($ra[$k], $class);
} else {
$result->$k = &$ra[$k];
}
}
return $result;
}
http://eye.cc php newsgroups
[Back to original message]
|