在这个问题之后,我使用这个函数将数组转换为对象,
function array_to_object($array)
{
if(!is_array($array)) {
return $array;
}
$object = new stdClass();
foreach($array as $key => $value)
{
$key = (string) $key ;
$object->$key = is_array($value) ? array_to_object($value) : $value;
}
return $object;
}
所以,
$obj = array('qualitypoint', 'technologies', 'India');
结果,
stdClass Object
(
[0] => qualitypoint
[1] => technologies
[2] => India
)
但是现在我需要将对象转换回数组,这样我才能得到这个结果,
Array
(
[0] => qualitypoint
[1] => technologies
[2] => India
)
是否可以?