xml方式封装通信数据方法
public static function xmlToEncode($data) { $xml = ""; foreach($data as $key => $value) { $attr = ""; if(is_numeric($key)) { $attr = " id='{$key}'"; $key = "item"; } $xml .= "<{$key}{$attr}>"; $xml .= is_array($value) ?self::xmlToEncode($value) : $value; $xml .= "</{$key}> "; } return $xml; }