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

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

使用php從json中的嵌套數(shù)組獲取數(shù)據(jù)

使用php從json中的嵌套數(shù)組獲取數(shù)據(jù)

我有來(lái)自 url feed 的 json。下面是一個(gè)示例。我沒(méi)有正確執(zhí)行 foreach 循環(huán)是問(wèn)題所在{    "useLive": true,    "models": [        {            "snapshotUrl": "https://img-eu.whatevercdn.com/eu7/previews/1537971705/5293074",            "widgetPreviewUrl": "https://img-eu.whatevercdn.com/eu7/previews/1537971705/5293074",            "id": 5293074,            "country": "",            "gender": "female",            "isNew": false,            "previewUrl": "https://st.whatevercdn.com/cdn/previews/b/a/a/baa515a42e75d80b0dc1e7a75bf4ea0f-full",            "previewUrlThumbBig": "https://st.whatevercdn.com/cdn/previews/b/a/a/baa515a42e75d80b0dc1e7a75bf4ea0f-thumb-big",            "previewUrlThumbSmall": "https://st.whatevercdn.com/cdn/previews/b/a/a/baa515a42e75d80b0dc1e7a75bf4ea0f-thumb-small",            "broadcastGender": "female",            "snapshotServer": "eu7",            "tags": ["autoTagPopular","keyword","keyword2"],            "topBestPlace": 0,            "username": "model1",            "languages": ["en"],            "stripScore": 998.5,            "token": "93021860dbebd5ba27e604f6b4b93754"        },        {            "snapshotUrl": "https://img-eu.whatevercdn.com/eu8/previews/1537971700/6492104",            "widgetPreviewUrl": "https://img-eu.whatevercdn.com/eu8/previews/1537971700/6492104",            "id": 6492104,            "country": "",            "gender": "female",            "isNew": false,            "previewUrl": "https://st.whatevercdn.com/cdn/previews/2/b/3/2b366955f5a66d73ee038d43bf77c99b-full",            "previewUrlThumbBig": "https://st.whatevercdn.com/cdn/previews/2/b/3/2b366955f5a66d73ee038d43bf77c99b-thumb-big",            "previewUrlThumbSmall": "https://st.whatevercdn.com/cdn/previews/2/b/3/2b366955f5a66d73ee038d43bf77c99b-thumb-small",        }    ],我只收到第一個(gè)用戶(hù)名,然后收到錯(cuò)誤消息。警告:/whatever 中的非法字符串偏移量“用戶(hù)名”有人能幫忙嗎?
查看完整描述

1 回答

?
忽然笑

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

您應(yīng)該在 foreach 中使用 $performers['models'] 數(shù)組,然后獲取用戶(hù)名它將正常工作嘗試以下代碼


$performers = json_decode($data, true); 

if(isset($performers['models'])){   

    foreach ($performers['models'] as $performer) {

        $info = (isset($performer["username"])) ? $performer["username"] : '';

        echo $info;

        echo "<br>";

    }   

}

輸出


model1

model2


查看完整回答
反對(duì) 回復(fù) 2023-05-12
  • 1 回答
  • 0 關(guān)注
  • 163 瀏覽

添加回答

舉報(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)