Omnipay\WechatPay\Helper::array2xml PHP Метод

array2xml() публичный статический Метод

public static array2xml ( $arr, $root = 'xml' )
    public static function array2xml($arr, $root = 'xml')
    {
        $xml = "<{$root}>";
        foreach ($arr as $key => $val) {
            if (is_numeric($val)) {
                $xml .= "<" . $key . ">" . $val . "</" . $key . ">";
            } else {
                $xml .= "<" . $key . "><![CDATA[" . $val . "]]></" . $key . ">";
            }
        }
        $xml .= "</xml>";
        return $xml;
    }

Usage Example

 /**
  * Send the request with specified data
  *
  * @param  mixed $data The data to send
  *
  * @return ResponseInterface
  */
 public function sendData($data)
 {
     $request = $this->httpClient->post($this->endpoint)->setBody(Helper::array2xml($data));
     $response = $request->send()->getBody();
     $responseData = Helper::xml2array($response);
     return $this->response = new CreateOrderResponse($this, $responseData);
 }
All Usage Examples Of Omnipay\WechatPay\Helper::array2xml