PHP Curl 数组只显示一个对象

在这里拉我的头发..


我的 JSON 输出是这样的:


Array ( 

    [total] => 1 

    [rows] => Array ( 

            [0] => Array ( 

                [id] => 45 

                [name] => MacBook Pro (Retina 15-inch Late 2013) 

                [asset_tag] => 3041974 

                [serial] => C02M73123455 

                ...etc...

如何仅输出[asset_tag]?


我在用 :


$responseArray=json_decode($results,true);

我试过了:


echo $responseArray['asset_tag'];


echo $responseArray[0]['asset_tag'];


echo $responseArray->asset_tag;

谢谢


茅侃侃
浏览 148回答 3
3回答

当年话下

要访问所有元素的 asset_tag:foreach ($responseArray['rows'] as $key => $value) {    echo $value['asset_tag'];}

青春有我

您可以asset_tag像这样获得集合:$assertTags = array_cloumn($responseArray['row'], 'asset_tag');
打开App,查看更多内容
随时随地看视频慕课网APP