PHP 在数组中加法运算操作实例代码
程序员文章站
2024-02-15 23:01:46
...
PHP 在数组中加法运算操作实例代码
- $a = array("a" => "apple", "b" => "banana");
- $b = array("a" => "pear", "b" => "strawberry", "c" => "cherry");
- $c = $a $b; // Union of $a and $b
- echo "Union of $a and $b: ";
- var_dump($c);
- $c = $b $a; // Union of $b and $a
- echo "Union of $b and $a: ";
- var_dump($c);
- ?>
- array(3) {
- ["a"]=>
- string(5) "apple"
- ["b"]=>
- string(6) "banana"
- ["c"]=>
- string(6) "cherry"
- }
- Union of $b and $a:
- array(3) {
- ["a"]=>
- string(4) "pear"
- ["b"]=>
- string(10) "strawberry"
- ["c"]=>
- string(6) "cherry"
- }
- ?>