开发者

PHP - Dealing with array

开发者 https://www.devze.com 2023-03-18 18:39 出处:网络
Suppose I have an array as below, how can I \"check if vid = 2, then get/echo tid\"? Array ( [29] => stdClass Object

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;
    }
  } 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号