简体   繁体   中英

Php Get Array elements

I have an array with and I want to get the oddGroupList element in a var.If I do it like this

$result=$arr_result['result'];
$betGroupList=$result['betGroupList'];
$betGroupList=$json['betGroupList'];
$oddGroupList=$json['oddGroupList'];

I cant get..please enlighten me!

这个结构

// Check this option:

// Static option:

    $result=$arr_result['result'];
    $betGroupList=$result['betGroupList'];
    $betId = $betGroupList[0]['betId'];
    $layoutType = $betGroupList[0]['layoutType'];
    $betDescription = $betGroupList[0]['betDescription'];
    $oddGroupList=$betGroupList[0]['oddGroupList'];
    $oddGroupDescription =$betGroupList[0]['oddGroupList'][0]['oddGroupDescription'];
    $oddList =$betGroupList[0]['oddGroupList'][0]['oddList'][0];
    $betCode = $oddList['betCode'];
    $oddValue = $oddList['oddValue'];
    $oddDescription = $oddList['oddDescription'];

// Dynamic Option: 

foreach($result['betGroupList'] as $betGroup){
echo $betGroup['betId'];
echo $betGroup['layoutType'];
echo $betGroup['betDescription'];
foreach($betGroup['oddGroupList'] as $oddGroup){
    echo $oddGroup['oddGroupDescription'];
foreach($oddGroup['oddList'] as $odd){
    echo $odd['betCode'];
    echo $odd['oddValue'];
    echo $odd['oddDescription'];
}

}
}

尝试这个 :

$arr_result['result']['betGroupList'][0]['oddGroupList'];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM