Return to Snippet

Revision: 43863
at April 1, 2011 13:30 by frederichoule


Initial Code
function object2array($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] = object2array($val);
        }
    } 
    else $new = $mixed;
    return $new;        
}

Initial URL

                                

Initial Description

                                

Initial Title
Object to Array

Initial Tags
object, array, json, convert

Initial Language
PHP