PHP function array_merge () specific method of merging arrays parsing _ PHP Tutorial

Source: Internet
Author: User
The PHP function array_merge () is used to parse the array. If the original array itself has been re-sorted, you must re-sort the new array after the array is merged. In the following example, we mayIf the original array itself has been re-sorted, after the array is merged, you must re-sort the generated new array. The following example describes how to use the PHP function array_merge:
 
 
  1. <? /* First create the first array */
  2. $FruitArray=Array("Apple", "orange", "banana", "Peach", "pear ");
  3. /* Create the second array */
  4. $VegArray=Array("Carrot", "green beans", "asparagus", "artichoke", "corn ");
  5. /* Now use the array_merge () function to combine the two arrays into a new array */
  6. $GoodfoodArray=Array_merge($ FruitArray, $ vegArray );
  7. /* Finally, the keys and values of all elements in the merged new array are displayed on the webpage */
  8. While (list ($ key, $ value) = each ($ goodfoodArray )){
  9. Echo "$ key: $ value <br> ";
  10. }
  11. ?>

The result is as follows:

0: apple

1: orange

2: banana

3: Peach

4: pear

5: carrot

6: green beans

7: asparagus

8: artichoke

9: corn

The usage of the PHP function array_merge () in array merging is shown above.


If the original array itself has been re-sorted, after the array is merged, you must re-sort the generated new array. The following example...

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.