Analysis of the difference between PHP array addition operation and Array_merge _php skills

Source: Internet
Author: User

Find problems

See a piece of code today, is so written, feel unfamiliar, the following paste out to see:

<?php
$array _one = [content];
$array _two = [content];
The key here
$array _result = $array _one + $array _two;
echo "<pre/>";
Print_r ($array _result);
? >

What I feel strange is that the array is added directly to the array $array_one , and $array_two I did the array merging operation in accordance with the array_merge() function, and I did not use the above method directly to do the operation.

Analysis is as follows

Here's a brief description of the difference between this approach and array_merge() the way the function is. When the "+" number is used for direct operation, is based on the array preceded by the "+" number, and if the array following the "+" number is exactly the same as the preceding array (exactly the same as the key and the value is the same), the data in the preceding array is the same. If you use the array_merge() opposite, you are using the following array as the benchmark.

Summarize

The above is the entire content of this article, I hope the content of this article for everyone's study or work can bring certain help, if you have questions you can message exchange.

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.