Object to array

function object_to_array($object){
	$new = NULL;
	if (is_object($object)) {
		$object = (array) $object;
	}
	if (is_array($object)) {
		$new = array();
		foreach ($object as $key => $val) {
			$key = preg_replace("/^(.*)/", "", $key);
			$new[$key] = $this->object_to_array($val);
		}
	} else {
		$new = $object;
	}
	return $new;
}

source

Comments are closed.