0

This code is from Drupal 7 php and is as follows:

if (!empty($data->_field_data['nid']['entity']->field_inst_address['und'][0]['administrative_area'])) {
      echo $data->_field_data['nid']['entity']->field_inst_address['und'][0]['administrative_area'];
} else echo " ";

I"m confused about this:

There is 2 -> signs. From my understanding, when you have a array, you can use key-value pairs and the => sign would separate them. The same is true for objects.

But why does this code have 2 on the same line, rather than just 1? Is this a multi-dimensional array thing going on? Can someone explain it please? Thank you.

J.K
  • 1,382
  • 1
  • 11
  • 27
Shawn
  • 1,175
  • 2
  • 11
  • 20
  • I can't see => only -> in your code – James Dewes Mar 31 '16 at 07:08
  • Oh crap, your right. Sorry, I meant -> and not => – Shawn Mar 31 '16 at 07:08
  • The `->` means that the item on the left hand side is an object, and the right hand side is a property. If you get more than one on the same line, it means that a property is also an object with its own properties (or it contains an object). – halfer Mar 31 '16 at 07:37

0 Answers0