Accessing sub-array data from theme_field__custom_content_type($variables) This is a mix of a PHP and a Drupal question.

I created a custom function...

theme_field__custom_content_type($variables)


I have the DEVEL module installed and have been using it profusely. I'm trying to modify the layout/look of a custom content through a childtheme I'm developing. I'm running into an issues that is leaving me scratching my head.

I have a custom content type [netrunner_card] and it has several fields that are taxonomy references. One field in particular is [field_card_subtype]. A card can have multiple subtypes... "Location," "Seedy," "Cloud," etc. What I want to do is to take those subtypes and place them next to another field like so:

field_card_type : field_card_subtype[0] - field_card_subtype[1] - etc


So that you would see output like:

Operation : Location - Seedy

ICE : AP - Trap

etc.

What I am doing is the following...
Yes, I am creating custom variables for this as it helps to collect everything in an easy to use package.

$blinksFieldName = $variables['element']['#field_name'];
switch( $blinksFieldName )
{
    case 'field_unique_card':
        $variables['card_is_unique'] = $variables['element']['#items'][0]['value'];
        break;
    case 'field_card_subtype':
        $variables['card_subtype_list'] = implode( " - ", $variables['element']['#items']);
        break;
    ...
}


When I kpr( $variables['card_subtype_list'] ) I get a string of the word 'Array'. I think that's because the breakdown of the variable in question is more like:

$variables['element']['#items'][0]['#title']


I'm very confused how you reach that level of the array when one of the placeholders is the array index... I had thought to do a for-next but I can't figure out how I would word it? Any help would be greatly appreciated.
I think I get what you're doing...you won't be able to straight implode the items array if it's a sequential set that you're using to build up a list of key/value pairs...

There are probably a few different ways to do that loop, I'd try something like this:

$keys = $values = array();
$count = 1;
foreach ($variables['element']['#items'] as $item) {
  if ($count++ % 2 == 1) {
    $keys[] = $item['#title'];
  }
  else {
    $values[] = $item['#title'];
  }
}

$output = '';
for ($i = 0; $i &lt; count($keys); $i++) {
  $output .= $keys[$i] . ' - ' . $values[$i] . '&lt;br /&gt;';
}
$variables['card_subtype_list'] = $output;


Hopefully someone will propose a better solution, that's not exactly elegant. Apologies if I've misunderstood.