public static function writeArray($array)
    {
        $data = array();
        foreach ($array as $var=>$val) {
            if (is_array($val) && !is_object($val)) {
                $data[$var] = self::writeArray($val);
            } else {
                $data[$var] = self::writeArrayItem($val);
            }
        }
        return serialize($data);
    }