PHP implementation of the two arrays add the method, PHP implementation of the array _php tutorial

Source: Internet
Author: User

PHP implements two arrays to add the method, the PHP implementation of the array addition


The example in this article describes how PHP implements the addition of two arrays. Share to everyone for your reference. Specific as follows:

Example 1:

<?PHP$ARR1 = Array ("A" = "Chaoyang", "B" and "Haidian"); $arr 2 = Array ("h" = "Xicheng", "a" and "Dongcheng", "b" = "Fengtai"); $arr = $ arr1 + $arr 2;echo "
";p Rint_r ($arr);? >

The output results are as follows:

Array (  [A] = Chaoyang  [b] = Haidian  [h] = Xicheng)

Change the order of additions, Example 2:

<?PHP$ARR1 = Array ("A" = "Chaoyang", "B" and "Haidian"); $arr 2 = Array ("h" = "Xicheng", "a" = "Dongcheng", "B" = "Fengtai"); $arr = $arr 2 + $arr 1;echo "
";p Rint_r ($arr);? 

The output is as follows:

array ([h] = Xicheng [A] = Dongcheng [b] = Fengtai) 

From the above two examples, you can see:

The

(1) addition is the following array, which is added to the previous array;
(2) The key name is not overwritten.

Hopefully this article will help you with your PHP programming.

http://www.bkjia.com/phpjc/959114.html www.bkjia.com true http://www.bkjia.com/phpjc/959114.html techarticle php implementation of the two arrays to add the method, PHP implementation of the array add the example of this article describes the PHP implementation of the two arrays to add the method. Share to everyone for your reference. As follows: Example 1: ...

  • 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.