Adding php arrays array('a')+array('b') results in array('a')_PHP Tutorial

WBOY
Release: 2016-07-21 15:16:05
Original
999 people have browsed it

I saw a question online:

The result of array("a")+array("b") is___

A.array("a","b")
B.array("b","a")
C.array("b")
D.array("a ")

Answer: D

When adding two arrays in PHP, why does the result remain unchanged?

Because, they are equivalent to array("0″=>"a")+array("0″=>"b"), their key names are the same, the former cannot be overwritten by the latter, if array("0″=>"a")+array("0″=>"b", "1″=>"c"), then the result is equal to array("0″=>"a" ,"1″=>"c")

What will happen if there are the same key names in the same array?

Look at a piece of code from the official PHP manual:

Copy code The code is as follows:
$switching = array( 10, // key = 0
5 5 => 6,
3 => 7,
'a' => 4,
11, // key = 6 (maxim um of integer-indices was 5)
                                                                                                                             // key = 8 (integer!)
                                                                                   );


It can be seen that if there are the same key names in the same array, the value of the previous key name will be overwritten (overwritten).

http://www.bkjia.com/PHPjc/325972.html

truehttp: //www.bkjia.com/PHPjc/325972.htmlTechArticleI saw a question on the Internet: The result of array("a")+array("b") is_ __ A.array("a","b") B.array("b","a") C.array("b") D.array("a") Answer: D Add two arrays in php , why the result is still not...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template