各位好,请教下API接口获取的如下这种Json数组怎么echo调用?想调用small_images下的单张图片地址,尝试foreach后用$tbitem->small_images[1]无结果。
[small_images] => SimpleXMLElement Object
(
[string] => Array
(
[0] => https://img.alicdn.com/i2/3653656057/O1CN01OV61yi1uc9jx7BaBT_!!3653656057.jpg
[1] => https://img.alicdn.com/i2/3653656057/O1CN01NJFLgC1uc9k3fIlEI_!!3653656057.jpg
[2] => https://img.alicdn.com/i1/3653656057/O1CN01PkE0Ny1uc9jzyPgES_!!3653656057.jpg
[3] => https://img.alicdn.com/i2/3653656057/O1CN01sevIs31uc9k2tZoAC_!!3653656057.jpg
)
)
<?php
$reqitem = new TbkItemInfoGetRequest;
$reqitem->setNumIids($num_iid);
$reqitem->setBizSceneId("1");
$reqitems = $c->execute($reqitem);
print_r ($reqitems);
?>
<?php
//抽取数组
foreach($reqitems as $iteminfo)
{ foreach($iteminfo as $tbitem)
{
?>
<?php }}?>
<?php echo $tbitem->small_images[1];?>
问题已解决,感谢wemk的提示!