src/Gateways/Wechat/Support.php
public static function toXml($data): string
    {
        if (!is_array($data) || count($data) <= 0) {
            throw new InvalidArgumentException('Convert To Xml Error! Invalid Array!');
        }

        $xml = '<xml>';
        foreach ($data as $key => $val) {
            $xml .= is_numeric($val) ? '<'.$key.'>'.$val.'</'.$key.'>' :
                                       '<'.$key.'><![CDATA['.$val.']]></'.$key.'>';
        }
        $xml .= '</xml>';

        return $xml;
    }
public static function toXml($data): string
    {
        if (!is_array($data) || count($data) <= 0) {
            throw new InvalidArgumentException('Convert To Xml Error! Invalid Array!');
        }

        $xml = '<xml>';
        foreach ($data as $key => $val) {
            $xml .= is_numeric($val) ? '<'.$key.'>'.$val.'</'.$key.'>' :
                                       '<'.$key.'><![CDATA['.$val.']]></'.$key.'>';
        }
        $xml .= '</xml>';

        return $xml;
    }
public static function toXml ( $ data ) : string { if ( ! is_array ( $ data ) || count ( $ data ) <= 0 ) { throw new InvalidArgumentException ( 'Convert To Xml Error! Invalid Array!' ) ; } $ xml = '<xml>' ; foreach ( $ data as $ key => $ val ) { $ xml .= is_numeric ( $ val ) ? '<' . $ key . '>' . $ val . '</' . $ key . '>' : '<' . $ key . '><![CDATA[' . $ val . ']]></' . $ key . '>' ; } $ xml .= '</xml>' ; return $ xml ; }
Convert array to xml.

@author yansongda <me@yansongda.cn>

@param array $data

@throws InvalidArgumentException

@return string
Convert array to xml .