Home >php教程 >php手册 >PHP 在数组中加法运算操作实例代码

PHP 在数组中加法运算操作实例代码

WBOY
WBOYOriginal
2016-06-13 10:39:391167browse

PHP 在数组中加法运算操作实例代码

  1.         $a = array("a" => "apple", "b" => "banana");
  2.         $b = array("a" => "pear", "b" => "strawberry", "c" => "cherry");
  3.         $c = $a $b; // Union of $a and $b
  4.         echo "Union of $a and $b: ";
  5.         var_dump($c);
  6.         $c = $b $a; // Union of $b and $a
  7.         echo "Union of $b and $a: ";
  8.         var_dump($c);
  9. ?>
  10.         array(3) {
  11.         ["a"]=>
  12.         string(5) "apple"
  13.         ["b"]=>
  14.         string(6) "banana"
  15.         ["c"]=>
  16.         string(6) "cherry"
  17.         }
  18.         Union of $b and $a:
  19.         array(3) {
  20.         ["a"]=>
  21.         string(4) "pear"
  22.         ["b"]=>
  23.         string(10) "strawberry"
  24.         ["c"]=>
  25.         string(6) "cherry"
  26.         }
  27. ?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn