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

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

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

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

PHP
繁華開滿天機(jī) 2023-05-12 15:43:14
我有來自 url feed 的 json。下面是一個示例。我沒有正確執(zhí)行 foreach 循環(huá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",        }    ],我只收到第一個用戶名,然后收到錯誤消息。警告:/whatever 中的非法字符串偏移量“用戶名”有人能幫忙嗎?
查看完整描述

1 回答

?
忽然笑

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

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


$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


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

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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