Php array merging and splitting instance analysis

Source: Internet
Author: User
This article mainly introduces the php array merging and splitting methods. The example analyzes the techniques related to array operations in php, such as array_merge, array_merge_recursive, and array_splice, for more information about how to merge and split php arrays, see the example in this article. Share it with you for your reference. The details are as follows:

<? Php $ array1 = array ("A", "B", "C", "D"); $ array2 = array ("1", "2", "3 ", "4"); $ array3 = array ("! "," @ "," # "," $ "); $ ArrayX = array_merge ($ array1, $ array2, $ array3 ); // combine the three numbers into print_r ($ arrayX);?>

<? Php $ array1 = array ("AA" => "A", "BB" => "B", "CC" => "C ", "DD" => "D"); $ array2 = array ("AA" => "1", "BB" => "2 ", "CC" => "3", "DD" => "4"); $ array3 = array ("AA" => "! "," BB "=>" @ "," CC "=>" # "," DD "=>" $ "); $ arrayX = array_merge ($ array1, $ array2, $ array3); // merge the array print_r ($ arrayX);?>

<? Php $ array1 = array ("AA" => "A", "BB" => "B", "CC" => "C ", "DD" => "D"); $ array2 = array ("AA" => "1", "BB" => "2 ", "CC" => "3", "DD" => "4"); $ array3 = array ("AA" => "! "," BB "=>" @ "," CC "=>" # "," DD "=>" $ "); $ arrayX = array_merge_recursive ($ array1, $ array2, $ array3); // merge the array print_r ($ arrayX);?>

<? Php $ array = array (1, 2, 3, 4, 5, 6, 7, 8, 9); $ arrayX = array_splice ($ array, 2, 6 ); // Obtain the 2nd to 7th elements of the array print_r ($ array); print_r ($ arrayX);?>

I hope this article will help you with php programming.

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.