note 94241 added to language.types.array

From: Date: Sun, 25 Oct 2009 01:16:20 +0000
Subject: note 94241 added to language.types.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-162036@lists.php.net to get a copy of this message
Here's a function to recursively convert objects to arrays and remove the special characters from private and protected variables. I use it with XML_Serializer to convert objects to XML. <?php 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; } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 68.198.84.155 ---- Manual Page -- http://www.php.net/manual/en/language.types.array.php Edit -- https://master.php.net/note/edit/94241 Del: integrated -- https://master.php.net/note/delete/94241/integrated Del: useless -- https://master.php.net/note/delete/94241/useless Del: bad code -- https://master.php.net/note/delete/94241/bad+code Del: spam -- https://master.php.net/note/delete/94241/spam Del: non-english -- https://master.php.net/note/delete/94241/non-english Del: in docs -- https://master.php.net/note/delete/94241/in+docs Del: other reasons-- https://master.php.net/note/delete/94241 Reject -- https://master.php.net/note/reject/94241 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#162036) next »