假设我有一个如下数组,我如何“检查vid = 2,然后获取/ echo tid”?
Array
(
[29] => stdClass Object
(
[tid] => 29
[vid] => 2
[name] => notebook
[description] =>
[weight] => 0
[language] =>
[trid] => 0
)
[97] => stdClass Object
(
[tid] => 97
[vid] => 1
[name] => DELL
[description] =>
[weight] => 0
[language] =>
[trid] => 0
)
)
答案 0 :(得分:5)
foreach($vids as $vid){
if($vid->vid == 2){
echo $vid->tid;
}
}
答案 1 :(得分:0)
它应该是:
foreach($tid as $key => $value){
if($value->vid == 2){
echo $value->tid;
}
}