我正在写一个小的网络应用程序为海洋潮汐使用PHP。我在弄清楚如何访问返回的数组( PHP转换为stdObject)时遇到了问题。
WSDL文件位于:http://opendap.co-ops.nos.noaa.gov/axis/webservices/highlowtidepred/wsdl/HighLowTidePred.wsdl
我的PHP代码是:
$wsdl = "http://opendap.co-ops.nos.noaa.gov/axis/webservices/highlowtidepred/wsdl/HighLowTidePred.wsdl";
$tides = new soapclient($wsdl);
$tideParams = array(
'stationId' => '8454000',
'beginDate' => '20110821 00:00',
'endDate' => '20110821 23:59',
'datum' => '0',
'unit' => '0',
'timeZone' => '0'
);
$tideRet = $tides->getHighLowTidePredictions($tideParams);
var_dump($tideRet);此转储返回:
object(stdClass)#2 (1) {
["HighLowValues"]=>
object(stdClass)#3 (1) {
["item"]=>
object(stdClass)#4 (2) {
["data"]=>
array(4) {
[0]=>
object(stdClass)#5 (3) {
["time"]=>
string(5) "00:35"
["pred"]=>
float(3.8)
["type"]=>
string(1) "H"
}
[1]=>
object(stdClass)#6 (3) {
["time"]=>
string(5) "05:45"
["pred"]=>
float(0.7)
["type"]=>
string(1) "L"
}
[2]=>
object(stdClass)#7 (3) {
["time"]=>
string(5) "12:49"
["pred"]=>
float(4.2)
["type"]=>
string(1) "H"
}
[3]=>
object(stdClass)#8 (3) {
["time"]=>
string(5) "18:32"
["pred"]=>
float(1.3)
["type"]=>
string(1) "L"
}
}
["date"]=>
string(10) "08/21/2011"
}
}
}我不知道如何理解这一点,我的谷歌搜索也没有多大帮助。任何帮助或指导都是非常感谢的。
发布于 2011-08-23 02:29:31
这是一个动态PHP对象。所有带引号的项都是属性名称,因此要访问数据数组:
$data = $tides->getHighLowTidePredictions($tideParams)
->HighLowValues
->item
->data;然后,如果您想要获取特定项的time属性,例如,您可以寻址该数组索引并查找time属性:
$data[0]->time;https://stackoverflow.com/questions/7151688
复制相似问题