I have the following array which contains both objects and arrays. How do I get only the specific values (for each object) based on their keys? I've tested and the array is displaying (see below) but I cannot isolate the 'name" value as needed.
I have tried the following code to get the name value:
case 'field_prgm_housing' :
$node = 'field_color';
$tids = field_get_items('node', $node, $key, $node->language);
$terms = taxonomy_term_load_multiple(array(), array('tid' => $tids));
$nameonly = $terms->[0]->name[0];
return = $nameonly;
break;
Colors (Array, 2 elements)
12 (Object) stdClass
tid (String, 2 characters ) 12
vid (String, 1 characters ) 3
name (String, 9 characters ) Blue
description (String, 0 characters )
format (String, 13 characters ) filtered_html
weight (String, 1 characters ) 0
vocabulary_machine_name (String, 15 characters ) colors
rdf_mapping (Array, 5 elements)
path (Array, 1 element)
13 (Object) stdClass
tid (String, 2 characters ) 13
vid (String, 1 characters ) 3
name (String, 8 characters ) Green
description (String, 0 characters )
format (String, 13 characters ) filtered_html
weight (String, 1 characters ) 0
vocabulary_machine_name (String, 15 characters ) colors
rdf_mapping (Array, 5 elements)
path (Array, 1 element)
$names = Array_column($array, "name")is that what you are looking for