第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何印 json_decode 第二層?

如何印 json_decode 第二層?

PHP
慕桂英3389331 2019-03-02 06:03:09
這是我 json_decode 對(duì)方回給我的 json 結(jié)果stdClass Object (     [attributes] => Array         (             [0] => stdClass Object                 (                     [attribute-id] => 5c6186217d4d0765152e42f7                     [attribute-type] => skill                     [parent-attribute-id] =>                      [parent-attribute-name] =>                      [name] => rgargrereshserhersh                     [slogan] => srehsrehrsehsrehre                     [description] => hrehrehresserhgserhserh                     [time-created] => 2019-02-11T14:54:57.073Z                     [available] => 1                     [time-available] => 2019-02-11T14:26:41.348Z                     [image-path] => http://127.0.0.1:9002/images/attribute/icon/15498952015c61862103aea-icon.JPG                     [cover-path] => http://127.0.0.1:9002/images/attribute/cover/15498952015c61862103aea-cover.jpg                 )         ) )請(qǐng)問(wèn)我要怎麼印出 name?他第一層有 「attributes」我原本的做法是<?=$data->{'name'};?>但是不行??多了第一層的「attributes」讓我沒(méi)辦法印,如何印第二層的KEY?PS:只會(huì)有一筆,所以不會(huì)用 foreach
查看完整描述

2 回答

?
HUWWW

TA貢獻(xiàn)1874條經(jīng)驗(yàn) 獲得超12個(gè)贊

或者 json_decode 成 array:

$data = json_decode($jsonStr, true);

或者直接取對(duì)象成員:

$data->attributes[0]->name

或者遍歷:

foreach ($data->attributes as $item) {
    var_dump($item->name);
}


查看完整回答
反對(duì) 回復(fù) 2019-03-29
?
翻翻過(guò)去那場(chǎng)雪

TA貢獻(xiàn)2065條經(jīng)驗(yàn) 獲得超14個(gè)贊

json_decode(xxx, true)

官方文檔 json_decode

assoc
當(dāng)該參數(shù)為 TRUE 時(shí),將返回 array 而非 object 。


查看完整回答
反對(duì) 回復(fù) 2019-03-29
  • 2 回答
  • 0 關(guān)注
  • 550 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)