php代码 数组转xml

 //生成xml格式数据
    public function ToXml($array)
    {
     
        if (!is_array($array) || count($array) <= 0) {
     
            return;
        }
        $xml = '';
        foreach ($array as $key => $val) {
     
            if (is_numeric($val)) {
     
                $xml .= "<" . $key . ">" . $val . " . $key . ">";
            } else {
     
                $xml .= "<" . $key . "> . $val . "]]> . $key . ">";
            }
        }
        $xml .= "";
        return $xml;
    }

你可能感兴趣的:(php,tp5,tp3整理,php)