I need to merge (sort of join) two arrays with both same keys, and in result i want to have the values of the first as keys of the second one :
Example :
$keyArray = [ "key1" => "map1", "key2" => "map1", "key3" => "map2", "key4" => "map3" ];
$valuesArray = [ "key1" => "value1", "key2" => "value2", "key3" => "value3", "key4" => "value3" ];
// expected result :
$mappedResultArray =
[
"map1" => [
"value1",
"value2"
],
"map2" => [
"value3"
],
"map3" => [
"valu3"
],
];
I know that this is possible by using php loops/foreach through both arrays, But I want to have a solution using PHP array_* functions (array_map, array_merge ....)