fork download
  1. <?php
  2.  
  3. $current = array(
  4. 'tool_situs' => array(
  5. 'template' => 'aa',
  6. 'title' => 'bb'
  7. ),
  8. 'style' => array(
  9. 'title' => array(
  10. 'color' => 'red',
  11. 'font-size' => '20px'
  12. )
  13. )
  14. );
  15.  
  16. $new = array(
  17. 'tool_situs' => array(
  18. 'title' => 'ddd'
  19. ),
  20. 'style' => array(
  21. 'title' => array(
  22. 'color' => 'blue',
  23. )
  24. )
  25. );
  26.  
  27. header('Content-type: text/plain');
  28.  
  29. $result = array_replace_recursive($current, $new);
  30.  
  31.  
  32. print_r($result);
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
Array
(
    [tool_situs] => Array
        (
            [template] => aa
            [title] => ddd
        )

    [style] => Array
        (
            [title] => Array
                (
                    [color] => blue
                    [font-size] => 20px
                )

        )

)