我有一个PHP Object数组正在从SOAP请求中返回给我。我需要过滤除空气质量指数和AqiDateTime对象和值之外的所有其他数据。所有其他数据并不需要,实际上会产生一个问题,因为我需要将它放在一个数组中,我正在为图形插件提供数据。该数组是值到插件。对不起,如果这是一个简单的问题,我是做Web项目的IT人员。如何过滤php对象数组
这里是对象的例子,因为它是被从的var_dump看到
object(stdClass)#2 (1) {
["CalculateSiteAQIByNaturalKeyJsonResult"]=>
object(stdClass)#3 (17) {
["AirQualityIndex"]=>
int(23)
["AqiDateTime"]=>
string(19) "2014-11-20T10:00:00"
["AqsUnitDescription"]=>
string(29) "Micrograms/cubic meter (25 C)"
["CategoryColorInteger"]=>
int(-16718848)
["CategoryDescription"]=>
string(4) "Good"
["FontColorInteger"]=>
int(-16777216)
["HealthAdvisory"]=>
string(4) "None"
["HealthEffects"]=>
string(4) "None"
["ParameterConcentration"]=>
float(24.67)
["ResponsibleAQIProgramID"]=>
string(36) "2d26a957-42f9-dd11-9b87-001e8c005352"
["ResponsibleAQIProgramName"]=>
string(4) "PM10"
["ResponsibleParameterID"]=>
string(36) "b8ab4bd9-89b0-4cdc-ba8a-3af9c038e5ba"
["ResponsibleParameterName"]=>
string(15) "PM10_(Standard)"
["SensitiveGroups"]=>
string(59) "People with respiratory disease are the group most at risk."
["SiteName"]=>
string(7) "BARSTOW"
["SourceSiteID"]=>
string(36) "3d104bd9-a9b7-e011-b9b9-444553544200"
["Unit"]=>
string(5) "UG/M3"
}
}
这是导致我下了正确的道路。我现在得到一个stdClass错误。 – GuitarGeek86 2014-11-20 22:01:14
PHP注意:未定义的属性:stdClass :: $ AirQualityIndex – GuitarGeek86 2014-11-20 22:01:42
#测试从AQI API获取JSON中的所有结果 - 使用的值是aqiDateTime,将其设置为PollTime变量。 $ result = $ client-> CalculateSiteAQIByNaturalKeyJson($ parameters); var_dump($ result); $ newArray = array('AirQualityIndex'=> $ result-> AirQualityIndex,'AqiDateTime'=> $ result-> AqiDateTime); – GuitarGeek86 2014-11-20 22:02:14