3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $a = array('a' => 'one', 'b' => 'two'); $b=array('a' => 'three', 'b' => 'four', 'c' => 'five'); //not a union of arrays' values echo '$a + $b : '; print_r ($a + $b); //a union of arrays' values echo "array_unique(array_merge($a,$b)):"; // cribbed from http://oreilly.com/catalog/progphp/chapter/ch05.html print_r (array_unique(array_merge($a,$b)));
based on SnRgj
Output for 5.4.0 - 7.1.0
$a + $b : Array ( [a] => one [b] => two [c] => five ) Notice: Array to string conversion in /in/o5h63 on line 10 Notice: Array to string conversion in /in/o5h63 on line 10 array_unique(array_merge(Array,Array)):Array ( [a] => three [b] => four [c] => five )
Output for 4.3.0 - 5.3.29
$a + $b : Array ( [a] => one [b] => two [c] => five ) array_unique(array_merge(Array,Array)):Array ( [a] => three [b] => four [c] => five )