<?php
$userData = [
[
"UID" => "5f10482574d83d4b726fe5",
"name" => "Yug Gill",
"orgID" => "5f10481d74d83d4b726",
"imageURL" => "female.png"
]
];
$userProductsData = [
[
"UPID" => "5f10482574d83d4b6fe007",
"UID" => "5f10482574d83d4b726fe5",
]
];
$userDetailsResult = [];
foreach ($userData as $key => $value) {
$userData[$key]["UPID"] = $userProductsData[$value["UID"]] ?? [];
}
Expected Output
$userData = [
[
"UID" => "5f10482574d83d4b726fe5",
"name" => "Yug Gill",
"orgID" => "5f10481d74d83d4b726",
"imageURL" => "female.png",
"UPID" => "5f10482574d83d4b6fe007"
]
];
i have two aray UID common for both array, now i want to take UPID from $userProductsData and push into $userData, i have tried not working properly, kindly anyone update my code please
?>
$userProductsData[$value["UID"]]becomes$userProductsData['5f10482574d83d4b726fe5'], and there is no element by that key in that array.$userProductsData, then inside loop each$userData, then use anif$userDetailsResult = [];?