Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Why is the result of php array array ("a") + array ("b") still array ("a")

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the "php array array (" a ") + array (" b ") why the result is still array (" a ") related knowledge, in the actual case operation process, many people will encounter such a dilemma, then let the editor lead you to learn how to deal with these situations! I hope you can read it carefully and be able to achieve something!

I 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

When the two arrays of php are added together, why does the result remain the same?

Because they are equivalent to array ("0" = > "a") + array ("0" = > "b"), they have the same key name, and 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 you have the same key name in the same array?

Take a look at the code in the official php manual:

The copy 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 there is the same key name in the same array, the value of the previous key name will be overwritten (overwritten).

"php array array (" a ") + array (" b ") why the result is still array (" a ") is introduced here, thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report