欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

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

程序员文章站 2024-02-15 23:01:46
...
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. ?>