src/Utils/DataParser.php
public static function toXml($values)
    {
        if (!is_array($values) || count($values) <= 0) {
            return false;
        }

        $xml = "<xml>";
        foreach ($values as $key => $val) {
            if (is_numeric($val)) {
                $xml.="<".$key.">".$val."</".$key.">";
            } else {
                $xml.="<".$key."><![CDATA[".$val."]]></".$key.">";
            }
        }
        $xml.="</xml>";
        return $xml;
    }
public static function toXml($values)
    {
        if (!is_array($values) || count($values) <= 0) {
            return false;
        }

        $xml = "<xml>";
        foreach ($values as $key => $val) {
            if (is_numeric($val)) {
                $xml.="<".$key.">".$val."</".$key.">";
            } else {
                $xml.="<".$key."><![CDATA[".$val."]]></".$key.">";
            }
        }
        $xml.="</xml>";
        return $xml;
    }
public static function toXml ( $ values ) { if ( ! is_array ( $ values ) || count ( $ values ) <= 0 ) { return false ; } $ xml = "<xml>" ; foreach ( $ values as $ key => $ val ) { if ( is_numeric ( $ val ) ) { $ xml .= "<" . $ key . ">" . $ val . "</" . $ key . ">" ; } else { $ xml .= "<" . $ key . "><![CDATA[" . $ val . "]]></" . $ key . ">" ; } } $ xml .= "</xml>" ; return $ xml ; }
输出xml字符
@param array $values
@return string|bool
输出xml字符