简体   繁体   English

Drupal7从数组中检索值

[英]Drupal7 Retrieve the values from an array

I have an array, that I want to retrieve the values from. 我有一个数组,我想从中检索值。 When I test the array with a print_r, it says that it has the right values. 当我用print_r测试数组时,它表示它具有正确的值。 But when I want to show them in their right places, it says that it has no values. 但是当我想在正确的位置展示它们时,它表示它没有价值。

function employees_items($nodeid, $language)
{
  $query  = db_query(//SOME QUERY);
  $rows   = array();

   foreach ($query as $row) {
    $rows[] = array(
        $row->nid,
        $row->title,
        $row->field_service_nummer_value,
        $row->field_support_email_value,
        $row->uri,
    );
}

    return $rows;   

} }

Here I want to retrieve the values...I want the value in $row->uri. 在这里我想检索值...我想要$ row-> uri中的值。 The errormessage: Trying to get property of non-object i employees_block_view() 错误消息:尝试获取非对象i employee_block_view()的属性

  function employees_block_view($delta = '')
 {
 if (array_key_exists($brandpage_id_page, $medarbejder_brandpages))
    {
     switch ($delta)
    {           

        case 'employees':                                   

        $employees = employees_items($brandpage_id_page, $lang_name);

        foreach ($employees as $row)
            {

              $block['content'] .= '<div class="img">';
              $block['content'] .= '<img style="width: auto; height: 100px;"    src="'.file_create_url($row->uri). '" alt="Vores support medarbejder" />';
   }
  return $block;
 }

I found the answer. 我找到了答案。 This is the way it must be written to read the value of 'uri'. 这是读取“ uri”值必须编写的方式。

 $block['content'] .= '<img style="width: auto; height: 100px;" src="'.file_create_url($row['uri']). '" alt="Vores support medarbejder" />';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM