Drupal terms and arrays
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);