Php array addition array ("a") + array ("B") result or array ("a") _ PHP Tutorial

Source: Internet
Author: User
The result of adding array ("a") + array ("B") to the php array is still array (""). I can see a question on the Internet: the result of array (A) + array (B) is ___. array (a, B) B. array (B, a) C. array (B) D. array (a) answer: Dphp adds two arrays. why is the result still not displayed on the Internet:

The result of array ("a") + array ("B") is ___

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

Answer: D

Why does the result remain unchanged when the php arrays are added?

Because they are equivalent to array ("0" => "a") + array ("0" => "B"), they have the same key name, the former cannot be overwritten by the latter. if it is array ("0" => "a") + array ("0" => "B ", "1" => "c"), then the result is equal to array ("0" => "a", "1" => "c ")

What happens if the same key name exists in the same array?

Read the code in the php official manual:

The code is as follows:

$ Switching = array (10, // key = 0
5 => 6,
3 => 7,
'A' => 4,
11, // key = 6 (maximum of integer-indices was 5)
'8' => 2, // key = 8 (integer !)
'02' => 77, // key = '02'
0 => 12 // the value 10 will be overwritten by 12
);

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

The result of using array ("a") + array ("B") is ___. array ("a", "B") B. array ("B", "a") C. array ("B") D. array ("a") answer: D php adds two arrays, why is the result still not...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.