Replace values among three array recursively using array_replace_recursive in PHP

Description

The following code shows how to replace values among three array recursively using array_replace_recursive.

Example


/*from   w ww.ja  v a  2s .c  o m*/
<?php
    $a1=array("a"=>array("red"),"b"=>array("green","blue"));
    $a2=array("a"=>array("yellow"),"b"=>array("black"));
    $a3=array("a"=>array("orange"),"b"=>array("HTML"));
    print_r(array_replace_recursive($a1,$a2,$a3));
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone