Return to Snippet

Revision: 49668
at July 28, 2011 01:11 by n19ht


Initial Code
function object_to_array($mixed){
	if(is_object($mixed)) $mixed = (array) $mixed;
	if(is_array($mixed)) {
		$new = array();
		foreach($mixed as $key => $val) {
			$key = preg_replace("/^\\0(.*)\\0/","",$key);
			$new[$key] = object_to_array($val);
		}
	}
	else $new = $mixed;
	return $new;       
}

Initial URL

                                

Initial Description
Esta función permite transformar un objeto a un array.

Initial Title
Transformar objeto a array PHP

Initial Tags
php, array

Initial Language
PHP