PHP Multi-Dim Array,替换值

时间:2011-07-14 05:35:35

标签: php

// Source
Array
(
    [name] => ben
    [country] => ca
    [msg] => Array
        (
            [type] => mail
            [read] => 0
            [content] => hello world
        )
 )
// Change 
Array
(
    [msg] => Array
        (
            [read] => 1
        )
)
// Result
Array
(
    [name] => ben
    [country] => ca
    [msg] => Array
        (
            [type] => mail
            [read] => 1
            [content] => hello world
        )
)
$result = php_function($source,$change);

什么php函数允许这种转换?

1 个答案:

答案 0 :(得分:1)

您正在寻找的功能是array_merge_recursive_simple()

请参阅array_merge_resursive

的php.net文档中的 the comment

修改: This one更优雅。