get all parent terms of a term using php - Notice: Array to string conversion
I think this is closer to what you want:

&lt;?php
    //term id of term that you are checking for top parent
    $term_tid = '9';
    $parent_terms = taxonomy_get_parents_all($term_tid);

    //top parent term has no parents so find it out by checking if it has parents
    foreach ($parent_terms as $parent) {
      $parent_parents = taxonomy_get_parents_all($parent-&gt;tid);
      if (empty($parent_parents)) {
        //this is top parent term
        return $parent;
      }
    }
?&gt;


Explanation:


You don't need the $top_parent_terms variable. You can return the first $parent you encounter that doesn't have a $parent_parent.
You were also probably having issues because you declare $top_parent_terms, but reference $top_parent_term (missing an 's').
Also, this bit $top_parent_term[] = $parent would produce a result like this:
$top_parent_term = array(0 =&gt; $parent) when you probably want $top_parent_term = $parent.
Note that the returned $parent variable will be an object, not an array. taxonomy_get_parents_all returns an array of term objects.