小编tay*_*317的帖子

无法将多维数组从 PHP 序列化为 XML

我正在通过 SoapUi 发送 SOAP 请求来测试此 Web 服务。

我目前有这个 PHP 数组:

array(7) {
  ["name"]=>
  string(9) "John Doe"
  ["date"]=>
  string(23) "2021-11-30 00:00:00.000"
  ["job"]=>
  string(31) "developer"
  ["where_from"]=>
  string(15) "france"
  ["address"]=>
  array(3) {
    ["country"]=>
    string(15) "france"
    ["city"]=>
    string(10) "paris"
    ["vat_number"]=>
    string(1) "123456"
  }
  ["items"]=>
  array(1) {
    [0]=>
    array(2) {
      ["cook"]=>
      string(7) "spoon"
      ["clean"]=>
      string(14) "vacuum"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我正在尝试将其转换为 XML:

function convertToXml($data, $name='root', &$doc=null, &$node=null){
    if ($doc==null){
        $doc = new DOMDocument('1.0','UTF-8');
        $doc->formatOutput = TRUE;
        $node = $doc;
    }

    if (is_array($data)){
        foreach($data as $var=>$val){
            if …
Run Code Online (Sandbox Code Playgroud)

php xml soap soapui laravel

6
推荐指数
1
解决办法
568
查看次数

标签 统计

laravel ×1

php ×1

soap ×1

soapui ×1

xml ×1