【发布时间】:2019-03-07 12:34:01
【问题描述】:
对此有真正的问题。我希望能够从通过 API 返回的数据中获取值。
即获得价值
$CM_user_customfields['Organisation'],
$CM_user_customfields->Organisation.
这可能吗?我尝试过循环并重建数组,但我总是得到类似的结果,而且可能是想多了。
我不能使用 [int] =>,因为自定义字段的数量会发生很大变化。
$CM_user_customfields = $CM_details->response->CustomFields ;
echo '<pre>' . print_r( $CM_user_customfields, true ) . '</pre>';
// returns
Array
(
[0] => stdClass Object
(
[Key] => Job Title
[Value] => Designer / developer
)
[1] => stdClass Object
(
[Key] => Organisation
[Value] => Jynk
)
[2] => stdClass Object
(
[Key] => liasoncontact
[Value] => Yes
)
[3] => stdClass Object
...
非常感谢,D.
【问题讨论】:
-
$CM_user_customfields->Organisation 在这种情况下,您没有密钥组织,因此您必须从 API 返回正确的数组。所以也许你可以像这样访问 $CM_user_customfields->Key 但你的问题不是很清楚
-
我想我已经明白你的意思了。您可以通过混合使用
array_search和array_column来做到这一点。