For you to remove the PHP array merge trouble _php tutorial

Source: Internet
Author: User
PHP is still more commonly used, so I studied the PHP array merge, here to take out and share with you, hope to be useful to everyone. This section focuses on additional questions about arrays in PHP, including merging and decomposing PHP arrays.

If you have not studied the previous three articles, it is recommended to look at the following: PHP array sorting. For arrays We can add, subtract and so on, first we look at the PHP array merge--array_merge (), + and so on "operator". If you just append the array to the back of another array, you can use "+". This is the same as we do the addition: $a = $array 1+ $array 2; only the "+" that needs to be specifically stated will make the number key name retained so that the original association remains unchanged, and array_merge () does not have this feature-it will be re-indexed. In addition Array_merge () also has a "sister" function array_merge_recursive ().

Array_merge_recursive () Usage

Array_merge_recursive () can combine two or more numbers together to form a combined array, array_merge_recursive () and Array_ The difference before merge () is that when a number group already exists in the result array, the function (Array_merge_recursive ()) takes two values into a new function, and Array_merge () simply overwrites the previously existing key/ value pairs.

How to use Array_combine ()

In the Help manual we learned that Array_combine () will get a new array, only a few of the original arrays must be of the same size and cannot be empty. The others don't say much, check the manual. Get your hands on your own.

Splitting a fraction group

Since you can merge, you can naturally split the fractional group. Array_slice () and other functions can complete the corresponding task, please check the Help manual.

Intersection of arrays

This section only introduces some functions, as for the usage is very simple, do not want to say more, lest the simple things become complicated.

 
  
  
  1. Array_intersect ()

The difference set of associative arrays Array_diff ()

 
  
  

Summary: In this chapter we learn about the PHP array problem, from the basic array creation to the sorting of the array. The ordering of the arrays is a key point, which can be enhanced in the application. This chapter is just a brief introduction to some of the knowledge. PHP in the operation of the array, PHP provides us with a large number of functions, but these functions are not possible to meet our needs, so this chapter also comes with the discussion of custom sorting functions and other issues, but not deep enough, I hope that in the future more comprehensive and profound study!


http://www.bkjia.com/PHPjc/446528.html www.bkjia.com true http://www.bkjia.com/PHPjc/446528.html techarticle PHP is still more commonly used, so I studied the PHP array merge, here to take out and share with you, hope to be useful to everyone. This section mainly learns about the other questions in PHP about arrays ...

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