So, basically, I'm creating a $tmpNode = node_load($nid). I'm then inputting dsm($tmpNode->array). My results are below:

#
... (Array, 1 element)

    *
      3 (Object) stdClass
          o
            tid (String, 1 characters ) 3
          o
            vid (String, 1 characters ) 1
          o
            name (String, 5 characters ) Books
          o
            description (String, 0 characters )
          o
            weight (String, 1 characters ) 0

My question is, I want to simply grab the name value from here.

$tmpNode->taxonomy->name doesn't work, since I'm one level too high for the name. It's in an array within the taxonomy array, titled by my term id ("3 (Object) stdClass"). But I can't figure out how to iterate down through that second array.

Help would be immensely appreciated.

Comments

How

How about:

$tmpNode->taxonomy[3]->name

Ah, that did it. Now I just

Ah, that did it. Now I just need to find a way to figure out the tid of any given object and pass it into the square brackets.

Is there a general rule about when to use [] and when to use ->?

Square brackets are for

Square brackets are for arrays, arrows are for objects. They are not interchangeable.

Full-time freelancer, always looking for work.
jaypan.com (my portfolio)

But couldn't I call

But couldn't I call $tmpNode->taxonomy, where taxonomy is an array?

Yes. $tmpNode is an object.

Yes. $tmpNode is an object. So you use the arrow.

Full-time freelancer, always looking for work.
jaypan.com (my portfolio)

nobody click here