PHP Manual
Prev | Chapter 11. Operators | Next

# Array Operators

The only array operator in PHP is the `+` operator. It appends the right handed array to the left handed, whereas duplicated keys are NOT overwritten.

    $a = array("a" => "apple", "b" => "banana");
    $b = array("a" =>"pear", "b" => "strawberry", "c" => "cherry");

    $c = $a + $b;

    var_dump($c);

    array(3) {
      ["a"]=>
      string(5) "apple"
      ["b"]=>
      string(6) "banana"
      ["c"]=>
      string(6) "cherry"
    }

Prev | Home | Next
String Operators | Up | Control Structures