Use the + with array in PHP

Description

The following code shows how to use the + with array.

Example


/*w w w . j a v  a2s .co  m*/
<?php
  //define a couple of arrays
  $a = array(
    0=>"Apple",
    2=>"Ball");
  $b = array(
    1=>"Cat",
    2=>"Dog");

  foreach(($a + $b) as $key=>$value)
  {
    print("$key: $value<br>\n");
  }
?>

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