PHP - 根据Key映射两个数组

PHP - Map two Arrays based on Key

用户数组

print_R($user_array);
Array
(
    [0] => Array
        (
            [SKILL_NAME] => Application Software
            [EXPERIENCE_BAND] => 15+
            [SITE_STATUS] => Onsite
            [NO_OF_RESOURCE] => 1
            [ACTUAL_HOURS] => 16
        )

    [1] => Array
        (
            [SKILL_NAME] => Application Software
            [EXPERIENCE_BAND] => 2-4
            [SITE_STATUS] => Onsite
            [NO_OF_RESOURCE] => 1
            [ACTUAL_HOURS] => 96
        )

)

值数组

print_R($value_array);
Array
(
    [RATE_PER_HOUR] => 80,50
    [MARKUP_PERCENT] => 5,10
    [TOTAL_COST] => 8064.00,880.00
)

爆炸值数组RATE_PER_HOUR

$rate_per_hour = explode(',', $array_data['RATE_PER_HOUR']);

输出如下。 MARKUP_PERCENTTOTAL_COST

也是如此
Array
(
    [0] => 80
    [1] => 50
)

我怎样才能映射到两个数组上方,以便输出如下所示。数组映射是基于key来维护数据正确的。

Array
(
    [0] => Array
        (
            [SKILL_NAME] => Application Software
            [EXPERIENCE_BAND] => 15+
            [SITE_STATUS] => Onsite
            [NO_OF_RESOURCE] => 1
            [ACTUAL_HOURS] => 16
            [RATE_PER_HOUR] => 80
            [MARKUP_PERCENT] => 5
            [TOTAL_COST] => 8064.00
        )

    [1] => Array
        (
            [SKILL_NAME] => Application Software
            [EXPERIENCE_BAND] => 2-4
            [SITE_STATUS] => Onsite
            [NO_OF_RESOURCE] => 1
            [ACTUAL_HOURS] => 96
            [RATE_PER_HOUR] => 50
            [MARKUP_PERCENT] => 10
            [TOTAL_COST] => 880.00
        )

)

展开值数组中的每个值。循环遍历并将它们添加到用户数组的相应元素中。

foreach ($value_array as $key => $data) {
    $data_array = explode(',', $data);
    foreach ($data_array as $index => $val) {
        $user_array[$index][$key] = $val;
    }
}

DEMO