我有一个数组,我想在var中获取oddGroupList元素。如果我这样做的话
$result=$arr_result['result'];
$betGroupList=$result['betGroupList'];
$betGroupList=$json['betGroupList'];
$oddGroupList=$json['oddGroupList'];
我无法得到......请启发我!
答案 0 :(得分:0)
// 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'];
}
}
}
答案 1 :(得分:0)
试试这个:
$arr_result['result']['betGroupList'][0]['oddGroupList'];