2 回答
TA贡献1858条经验 获得超8个赞
试试这个。
$userData = [
[
"UID" => "5f10482574d83d4b726fe5",
"name" => "Yug Gill",
"orgID" => "5f10481d74d83d4b726",
"imageURL" => "female.png"
]
];
$userProductsData = [
[
"UPID" => "5f10482574d83d4b6fe007",
"UID" => "5f10482574d83d4b726fe5",
]
];
$userDetailsResult = [];
foreach ($userProductsData as $key => $value) {
$userData[$key]["UPID"] = $value['UPID'];
}
print_r($userData);
TA贡献1887条经验 获得超5个赞
您$userProductsData是一个常规数组,它有索引 0、1、2 等...然后您尝试通过字符串 key 从此数组中获取项目"5f10482574d83d4b726fe5"。
$userProductsData应该是这样的键数组:
$userProductsData = [
"5f10482574d83d4b726fe5" => [
"UPID" => "5f10482574d83d4b6fe007",
"UID" => "5f10482574d83d4b726fe5",
],
];
然后你可以通过 key 从这个数组中获取一个项目"5f10482574d83d4b726fe5"。
- 2 回答
- 0 关注
- 127 浏览
添加回答
举报