请求 php foreach stdclass 示例
Request for php foreach stdclass example
谁能解释一下我如何在 php 的 foreach 循环中从 entry_list 获取值?
以下是return数据结构。请帮忙。
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
)
试试这个,
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
}
}
第一行给出了示例值...同样,所有值都将打印出来。
谁能解释一下我如何在 php 的 foreach 循环中从 entry_list 获取值?
以下是return数据结构。请帮忙。
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
)
试试这个,
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
}
}
第一行给出了示例值...同样,所有值都将打印出来。