function array_to_object($array, &$object)
{
foreach ($array as $key => $value) {
if (is_array($value)) {
$object->$key = new stdClass();
array_to_object($value, $object->$key);
} else {
$object->$key = $value;
}
}
return $object;
}
function arrayToObject($array)
{
$object= new stdClass();
return array_to_object($array, $object);
}
$configArr = array(
'NAME' => 'stack over flow',
'AGE' => 28,
'SEX' => 'MALE',
);
$configObj = arrayToObject($configArr);
var_dump($configObj);
class stdClass#1 (3) {
public $NAME => string(15) "stack over flow"
public $AGE => int(28)
public $SEX => string(4) "MALE"
}