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

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

循環(huán)由關聯(lián)數(shù)組組成的數(shù)組

循環(huán)由關聯(lián)數(shù)組組成的數(shù)組

PHP
慕田峪7331174 2022-01-08 14:58:48
我有一個看起來像這樣的數(shù)組:[   {    "positional_index":"1.3",    "sourceid":10409,    "language": "Malayalam",    "field_gita_10409_text": "Behold, O Teacher! this mighty army of the sons of Pandu, arrayed by the son of Drupada, thy wise disciple."   },   {    "positional_index":"1.2",    "sourceid":10409,    "language": "Devanagari",    "field_gita_10409_text": "1.1 Dhritarashtra said What did my people and the sons of Pandu do when they had assembled together eager for battle on the holy plain of Kurukshetra, O Sanjaya."   },]我應該使用 foreach 循環(huán)來訪問每個鍵。例如,如果 key = field_gita_10409_text,我必須使用 php 中的 explode() 函數(shù)來提取值 10409 等。在這種情況下,我不知道如何使用 foreach 循環(huán),因為該數(shù)組包含 2 個關聯(lián)數(shù)組。請告訴我。
查看完整描述

2 回答

?
汪汪一只貓

TA貢獻1898條經(jīng)驗 獲得超8個贊

在循環(huán)內(nèi)循環(huán):


foreach ($array as $item){

        foreach ($item as $key=>$value){

            //do stuff

        }

    }


查看完整回答
反對 回復 2022-01-08
?
HUX布斯

TA貢獻1876條經(jīng)驗 獲得超6個贊

您需要內(nèi)部循環(huán)來獲取鍵和值。


$array = json_decode($json);


foreach ($array as $innerArray){

        foreach ($innerArray as $key=>$value){

            if($key == 'field_gita_10409_text'){

              $exp = explode($value);

            }

        }

    }


查看完整回答
反對 回復 2022-01-08
  • 2 回答
  • 0 關注
  • 129 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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