0

有人可以解释一下我如何在 php 的 foreach 循环中从 entry_list 获取值?

以下是返回数据结构。请帮忙。

      stdClass Object
(
[result_count] => 1
[total_count] => 1
[next_offset] => 1
[entry_list] => Array
    (
        [0] => stdClass Object
            (
                [id] => 6adfd27d-0a48-48c9-97b2-5639c6d9e697
                [module_name] => Leads
                [name_value_list] => stdClass Object
                    (
                        [assigned_user_name] => stdClass Object
                            (
                                [name] => assigned_user_name
                                [value] => Administrator
                            )

                        [modified_by_name] => stdClass Object
                            (
                                [name] => modified_by_name
                                [value] => Administrator
                            )

                        [created_by_name] => stdClass Object
                            (
                                [name] => created_by_name
                                [value] => Administrator
                            )

                        [id] => stdClass Object
                            (
                                [name] => id
                                [value] => 6adfd27d-0a48-48c9-97b2-5639c6d9e697
                            )
4

1 回答 1

1

试试这个,

foreach($arr->entry_list as $row) {

     foreach($row->name_value_list as $key => $val){

          echo $key;// will echo assigned_user_name
          echo $val->name; // assigned_user_name
          echo $val->value; // Administrator

     }

}

第一行给出了示例值......同样,所有值都将被打印出来。

于 2015-11-14T04:42:23.540 回答