如何在PHP中连接数组值?

前端之家收集整理的这篇文章主要介绍了如何在PHP中连接数组值?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有阵列1:
Array
(
    [0] => Array
        (
            [recomendation_id] => 3588
            [employee_id] => 90141063
            [attendance_type_id] => 2
            [start_dtm] => 2016-05-17 10:32:00
            [end_dtm] => 
            [request_message] => test notif
            [recomendation_status_id] => 1
            [last_update_dtm] => 2016-05-17 10:32:43
            [employee_name] => Nike Yulistia Angreni
            [attd_type_name] => Permittance
            [status_name] => Request
        )

)

阵列2:

Array
(
    [0] => Array
        (
            [valuator1] => Wulan  Lastia Permana
        )
)

我想在一个数组中创建数组值.我想要这样的结果:

Array
(
    [0] => Array
        (
            [recomendation_id] => 3588
            [employee_id] => 90141063
            [attendance_type_id] => 2
            [start_dtm] => 2016-05-17 10:32:00
            [end_dtm] => 
            [request_message] => test notif
            [recomendation_status_id] => 1
            [last_update_dtm] => 2016-05-17 10:32:43
            [employee_name] => Nike Yulistia Angreni
            [attd_type_name] => Permittance
            [status_name] => Request
            [valuator1] => Wulan  Lastia Permana
        )
)

有可能像那样加入吗?

你必须使用 array_replace_recursive
<?PHP

$arr1 = Array
(
     Array
        (
            "recomendation_id" => 3588,"employee_id" => 90141063,"attendance_type_id" => 2,"start_dtm" => "2016-05-17 10:32:00","end_dtm" => "","request_message" => "test notif","recomendation_status_id" => 1,"last_update_dtm" => "2016-05-17 10:32:43","employee_name" => "Nike Yulistia Angreni","attd_type_name" => "Permittance","status_name" => "Request"
        )

);
$arr2 = Array
(
    Array
        (
            "valuator1" => "Wulan  Lastia Permana"
        )
);

print_r(array_replace_recursive($arr1,$arr2));

结果:

Array
(
    [0] => Array
        (
            [recomendation_id] => 3588
            [employee_id] => 90141063
            [attendance_type_id] => 2
            [start_dtm] => 2016-05-17 10:32:00
            [end_dtm] => 
            [request_message] => test notif
            [recomendation_status_id] => 1
            [last_update_dtm] => 2016-05-17 10:32:43
            [employee_name] => Nike Yulistia Angreni
            [attd_type_name] => Permittance
            [status_name] => Request
            [valuator1] => Wulan  Lastia Permana
        )

)

你的Eval

如果您使用array_merge_recursive,您的output将是:

Array
(
    [0] => Array
        (
            [recomendation_id] => 3588
            [employee_id] => 90141063
            [attendance_type_id] => 2
            [start_dtm] => 2016-05-17 10:32:00
            [end_dtm] => 
            [request_message] => test notif
            [recomendation_status_id] => 1
            [last_update_dtm] => 2016-05-17 10:32:43
            [employee_name] => Nike Yulistia Angreni
            [attd_type_name] => Permittance
            [status_name] => Request
        )

    [1] => Array
        (
            [valuator1] => Wulan  Lastia Permana
        )

)
原文链接:https://www.f2er.com/php/132193.html

猜你在找的PHP相关文章