Return to Snippet

Revision: 30683
at August 19, 2010 08:47 by jmiller


Initial Code
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("/^\\0(.*)\\0/", "", $key);
			$new[$key] = $this->object_to_array($val);
		}
	} else {
		$new = $object;
	}
	return $new;
}

Initial URL


Initial Description
Pass in object. Returns array.

Initial Title
Object to array

Initial Tags
object, array, convert

Initial Language
PHP