PHP - Dealing with array
Suppose I have an array as below, how can I "check if vid = 2, then get/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
开发者_StackOverflow[language] =>
[trid] => 0
)
)
foreach($vids as $vid){
if($vid->vid == 2){
echo $vid->tid;
}
}
it should be:
foreach($tid as $key => $value){
if($value->vid == 2){
echo $value->tid;
}
}
精彩评论