2016-08-23 29 views
0

我創建了一個查詢,僅獲取一些具有特定條件的用戶。我將這些用戶存儲到一個數組中。我的問題是從這個數組中取回特定的值,如ids。Wordpress - 訪問陣列中的Wp對象並檢索所有ID

print_r我的功能myfriends()和我得到的是這樣的:

$myfriends = myfriends($user_id); //good 

$myfriendsids = $myfriends->ID; //not working 
$myfriendsids = $myfriends[0]->ID; //not working 
$myfriendsids = $myfriends[0][0]->ID; //not working 
$myfriendsids = $myfriends[0][0][0]->ID; //only the first user id! 

//even tried 
$myuserdata = $myfriends->data; //not working 
$myuserids = $myuserdata->ID; //not working 

Array ( 
[0] => Array ( 
    [0] => Array ( 
     [0] => WP_User Object ( 
      [data] => stdClass Object ( 
       [ID] => 48 
       ) 
      ) 
     [1] => WP_User Object ( 
      [data] => stdClass Object ( 
       [ID] => 47 
       ) 
      ) 
    ) 
[1] => 
) 

我需要檢索的陣列所有用戶的ID,這樣我已經試過

如何獲得我擁有的所有用戶ID? NB。 「不工作」意味着我所有的變量和我什麼也得不到。 謝謝!

回答

0

調整了一下我訪問並存儲了帶foreach循環的ID值$myfriendsids。涼。