Drupal terms and arrays I am struggling a bit with the array structure of Drupal.

I am using PHP in a contextual filter inside views. I have the same vocab on both a content type and user via profile2. I manage to get the filter working for single term. The key is in how I return the values at the end of my function. 

return $items[0]['tid'];


This returns 2, a correct tid on user profile taxonomy.

I can also get other values by using:

return $items[1]['tid'];


This returns 4, also a correct tid.

How would I be able to say?

return $items[ALL_ARRAYS]['tid'];


So that it would print all the term ids associated with that vocab?

My PHP code:

global $user;
$profiles = profile2_load_by_user($user);
    foreach ($profiles as $profile) {
      if ($items = field_get_items('profile2', $profile, 'field_your_interests')) {
        break;
      }
    }
$tids = array();
foreach ($items as $item) {
  $tids[] = $item['tid'];
}
//returns nothing in view, not sure if a contextual filter can handle 'and'?
//return implode(',', $tids);

//This works with 1st value in array 
//return $items[0]['tid'];

//This doesn't return anything
  return $tids;
There are a few ways you can do this, but this is probably the most straightforward:

$tids = array();
foreach ($items as $item) {
  $tids[] = $item['tid'];
}

// Return this if you want to use "or" logic
return implode('+', $tids);

// Return this if you want to use "and" logic
return implode(',', $tids);