Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json Laravel Simplexml错误无法将复杂类型分配给属性_Json_Xml_Laravel_Simplexml - Fatal编程技术网

Json Laravel Simplexml错误无法将复杂类型分配给属性

Json Laravel Simplexml错误无法将复杂类型分配给属性,json,xml,laravel,simplexml,Json,Xml,Laravel,Simplexml,接收到错误尝试将新数组放入对象时,尚无法将复杂类型指定给属性 $file = '/path/file.xml'; $terms = array( 'Title' => [ 'name' => 'name' ] ); $term = json_decode( json_encode($terms), true); $data = simplexml_load_file($file);

接收到错误尝试将新数组放入对象时,尚无法将复杂类型指定给属性

    $file = '/path/file.xml';

    $terms = array(
        'Title' => [
            'name' => 'name'
        ]
    );

    $term =  json_decode( json_encode($terms), true);

    $data = simplexml_load_file($file);
    list($result) = $data->xpath('(//Key1/Key2)');
    $number = count($result);
    $data->Key1[$number] = $term;
    $data->asXML($file);

欢迎来到Stackoverflow!你能把你收到的错误信息准确地贴出来吗?非常感谢。什么是
->Key1[$number]
在这里,您希望通过编写这样的对象属性得到什么