[英]Cannot use object of type stdClass as array
I am trying to fetch an array from a .net WebService and echo it, but it keeps saying: "Cannot use object of type stdClass as array" if I use var dump i get this so the array is in the variable. 我试图从.net WebService获取一个数组并回显它,但它一直说:“不能将stdClass类型的对象用作数组”,如果我使用var dump我得到了这个,所以数组在变量中。 Do i need to do something special to it because it's from a .net webservice??? 我是否需要对它进行特殊处理,因为它来自.net Web服务??? I have no experince in C#. 我没有C#的经验。 The first function is working just fine. 第一个功能运行正常。
object(stdClass)#4 (1) { ["string"]=> array(4) { [0]=> string(3) "Ivo" [1]=> string(6) "Peter" [2]=> string(5) "Simon" [3]=> string(6) "Michel" } } object(stdClass)#4(1){[“”“] =>数组(4){[0] =>字符串(3)” Ivo“ [1] =>字符串(6)” Peter“ [2] = >字符串(5)“ Simon” [3] =>字符串(6)“ Michel”}}
<?php
$client = new SoapClient("http://xavier.monkees.com/XavierService.svc?singleWsdl");
$response = $client->CheckName(array(
"name" => "$naam"));
$response_array = $client->GetNames()->GetNamesResult;
echo $response_array[1];
?>
Looking at the dump of your object, it looks like the first subscript is "string" 查看对象的转储,看起来第一个下标是“字符串”
object(stdClass)#4 (1) { ["string"]=> array(4) { [0]=> string(3) "Ivo" [1]=> string(6) "Peter" [2]=> string(5) "Simon" [3]=> string(6) "Michel" } }
Try 尝试
$response_array = $client->GetNames()->GetNamesResult->string[1];
or 要么
$response_array = $client->GetNames()->GetNamesResult["string"][1];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.