Able to see a variable in print_r()'s output, but not sure how to access it in code

后端 未结 9 843

I googled, installed Devel, Drupal for Firebug, but I can\'t find it.

I found what I want, I know where it is; I just don\'t know how to g

9条回答
  •  面向向阳花
    2020-11-22 03:07

    If this is your object:

    field_image (Object) stdClass 
      handler (Object) views_handler_field_field 
        view (Object) view 
          result (Array, 2 elements) 
            0 (Object) stdClass 
              _field_data (Array, 1 element) 
                nid (Array, 2 elements) 
                  entity (Object) stdClass
                    field_image (Array, 1 element) 
                      und (Array, 1 element)
                        0 (Array, 11 elements)                                      
                          filename (String, 23 characters ) FILENAME.jpg
    

    I'd guess you can find it using:

    field_image->handler->view->result[0]->_field_data['nid'][entity]->field_image['und'][0]['filename]
    

    Could be a mistake in there, but the general Idea is: if you have an object, get the variable using ->, and if you have an array, use [key].

提交回复
热议问题