I have twomultidimensional array in below format
$skillInfo = Array
(
"Mechanical" => Array
(
"0" => 100
"1" => 400
)
"Understanding" => Array
(
"0" => 200
)
"Application/Appreciation" => Array
(
"0" => 300
)
);
$skillMaster = [
["skillID" => 1, "skillName" => "Mechanical"],
["skillID" => 2, "skillName" => "Understanding"],
["skillID" => 3, "skillName" => "Application/Appreciation"]
];
$skillMaster skillName is the same as $skillInfo keys, so we can replace $skillInfo keys from $skillMaster skillID.
Expected output
Array
(
[1] => Array
(
[0] => 100
[1] => 400
)
[2] => Array
(
[0] => 200
)
[3] => Array
(
[0] => 300
)
)
my code
foreach($skillInfo as $key1 => $val1){
$skillInfo[$key1][$skillMaster[$val1["skillID"]]] = $skillMaster[$val1["skillID"]] ?? [];
}
above code is not working as expected output, kindly anyone help me out.
$val1is a$skillInfoelement, it doesn't haveskillID.$skillInfoarray, i want to replace instead of nameskillID$val1['skillID']would work?