【发布时间】:2012-11-14 02:41:37
【问题描述】:
我正在使用亚马逊产品广告 API。值作为多维对象返回。
看起来像这样:
object(AmazonProduct_Result)#222 (5) {
["_code":protected]=>
int(200)
["_data":protected]=>
string(16538)
array(2) {
["IsValid"]=>
string(4) "True"
["Items"]=>
array(1) {
[0]=>
object(AmazonProduct_Item)#19 (1) {
["_values":protected]=>
array(11) {
["ASIN"]=>
string(10) "B005HNF01O"
["ParentASIN"]=>
string(10) "B008RKEIZ8"
["DetailPageURL"]=>
string(120) "http://www.amazon.com/Case-Logic-TBC-302-FFP-Compact/dp/B005HNF01O?SubscriptionId=AKIAJNFRQCIJLTY6LDTA&tag=*********-20"
["ItemLinks"]=>
array(7) {
[0]=>
object(AmazonProduct_ItemLink)#18 (1) {
["_values":protected]=>
array(2) {
["Description"]=>
string(17) "Technical Details"
["URL"]=>
string(217) "http://www.amazon.com/Case-Logic-TBC-302-FFP-Compact/dp/tech-data/B005HNF01O%3FSubscriptionId%3DAKIAJNFRQCIJLTY6LDTA%26tag%*******-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3DB005HNF01O"
}
}
[1]=>
object(AmazonProduct_ItemLink)#17 (1) {
["_values":protected]=>
array(2) {
我的意思是它在对象内部也有数组。我想将它们全部转换成一个多维数组。
【问题讨论】:
-
为什么需要这个数组?许多常见的数组任务(如 foreach)也可以与对象一起使用。
-
如何检查对象中是否存在值?我尝试过使用 isset,但它不起作用。
-
因为它是一个对象,所以值应该一直存在。您应该检查它是否设置为可用的东西(或只是空)
-
谢谢玻璃先生。当我将它与 is_null 函数一起使用时它可以工作。谢谢
标签: php arrays multidimensional-array