My variable ($tax_terms
) contain this information:
Array
(
[5] => stdClass Object
(
[term_id] => 120
[name] => work
[slug] => work
)
)
I want to display the name. what would be the php syntax to display the name.
You can use:
$tax_terms[5]->name;
Since $tax_terms
seems to be an array, and the value at the 5th key is an object, you would access name
as follows:
$name = $tax_terms[5]->name;
You might wish to call array_values()
on the array to force a re-index, since it looks like someone maybe used unset()
with the original array. Doing so would make accessing the values more logical.
For example:
$tax_terms = array_values($tax_terms);
$name = $tax_terms[0]->name;
Try this:
$tax_terms[5]->name