title: Access protected object in array in PHP
body: <p>I am trying to access the following and need to get the value of <strong>[vid]</strong> array cell.</p>
  
  <pre><code>FieldCollectionItemEntity Object
  (
      [fieldInfo:protected] =&gt; 
      [hostEntity:protected] =&gt; stdClass Object
          (
              **[vid]** =&gt; 119
              [uid] =&gt; 1
              [title] =&gt; My Page Name
              [log] =&gt; 
              [status] =&gt; 1
              [comment] =&gt; 1
              [promote] =&gt; 0
              [sticky] =&gt; 0
              [vuuid] =&gt; 3304d1cf-e3cf-4c5a-884a-4abb565ddced
              [nid] =&gt; 119
              [type] =&gt; subpage
              [language] =&gt; und
              [created] =&gt; 1408621327
              [changed] =&gt; 1408640191
              [tnid] =&gt; 0
              [translate] =&gt; 0
              [uuid] =&gt; 39145013-6637-4062-96e7-1b4589609c4f
              [revision_timestamp] =&gt; 1408640191
  </code></pre>
  
  <h2>I tried the following, but I guess I don't have a clue from here:-</h2>
  
  <pre><code>  $mything = new myClass;
    print $mything-&gt;accessObjectArray();
  
  
    class myClass {
        protected $var;
  
  
        function accessObjectArray(){
          return $this-&gt; $var;
        }
        //other member functions
    }
  </code></pre>
  
  <h2>Update</h2>
  
  <p>I actually only have access to the variable $content which has the following multi-dimensional arrays. All I want is to get the array cell's value of <strong>[vid]</strong>.</p>
  
  <p>To do that, I could print <code>$content["field_image_title"]["#object"]</code> but after that it's protected. That's where I am wondering that how can I access this array. I unfortunately do not have access <code>FieldCollectionItemEntity</code> to include in my page.</p>
  
  <p>On doing this:- I get the following output:-</p>
  
  <pre><code> print_r($content);
  
  
  Array
  (
      [field_image_title] =&gt; Array
          (
              [#theme] =&gt; field
              [#weight] =&gt; 0
              [#title] =&gt; Image Title
              [#access] =&gt; 1
              [#label_display] =&gt; hidden
              [#view_mode] =&gt; full
              [#language] =&gt; und
              [#field_name] =&gt; field_image_title
              [#field_type] =&gt; text
              [#field_translatable] =&gt; 0
              [#entity_type] =&gt; field_collection_item
              [#bundle] =&gt; field_image_collection
              [#object] =&gt; FieldCollectionItemEntity Object
                  (
                      [fieldInfo:protected] =&gt; 
                      [hostEntity:protected] =&gt; stdClass Object
                          (
                              [vid] =&gt; 119
                              [uid] =&gt; 1
                              [title] =&gt; My Page Name
                              [log] =&gt; 
                              [status] =&gt; 1
                              [comment] =&gt; 1
                              [promote] =&gt; 0
                              [sticky] =&gt; 0
                              [vuuid] =&gt; 3304d1cf-e3cf-4c5a-884a-4abb565ddced
                              [nid] =&gt; 119
                              [type] =&gt; subpage
                              [language] =&gt; und
                              [created] =&gt; 1408621327
                              [changed] =&gt; 1408640191
                              [tnid] =&gt; 0
                              [translate] =&gt; 0
                              [uuid] =&gt; 39145013-6637-4062-96e7-1b4589609c4f
                              [revision_timestamp] =&gt; 1408640191
                              [revision_uid] =&gt; 1
  </code></pre>