PHP array operation subtotal

Source: Internet
Author: User
: This article mainly introduces the Subtotal of PHP Array Operations. if you are interested in the PHP Tutorial, please refer to it. Arrays in PHP are the most basic and most commonly used operations. PHP has many built-in convenient functions for us to use. However, the translation of official documents is sometimes not so easy to understand, in addition, some functions do not need to be confused during the time interval. Good memory is not as bad as a pen, I will slowly record some of the commonly used functions here, and make a demo to understand how to use them.

1. array merging

Array merging is a simple thing, but the simpler the thing, the easier it is to forget, especially when it is rarely used ....

 "; $ A = [, 3]; $ B = [, 6]; // 1. PHP array merging function $ c = array_merge ($ a, $ B); var_dump ($ c); // 2. the directly added array is sequentially overwritten by the key. the subsequent key overwrites the previous key value $ c = $ a + $ B; var_dump ($ c); // 3. $ c = $ B + $ a; var_dump ($ c); // 4. to understand this, array_push ($ a, $ B); var_dump ($ );
Result:
1.array(6) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)  [3]=>  int(4)  [4]=>  int(5)  [5]=>  int(6)}2.array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}3.array(3) {  [0]=>  int(4)  [1]=>  int(5)  [2]=>  int(6)}4.array(4) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)  [3]=>  array(3) {    [0]=>    int(4)    [1]=>    int(5)    [2]=>    int(6)  }}

The above introduces the PHP array operation subtotal, including the content, hope to be helpful to friends who are interested in the PHP Tutorial.

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.