-
- $array1 = array("A","B","C","D");
- $array2 = array("1","2","3", "4");
- $array3 = array("!","@","#","$");
- $arrayX = array_merge($array1, $array2, $array3); //Merse 3 arrays Merge together
- print_r($arrayX);
- ?>
Copy the code
Example 2, merge php arrays.
-
- $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 arrays
- print_r($arrayX);
- ?>
Copy code
Example 3, php array merge.
-
- //by bbs.it-home.org
- $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 arrays
- print_r($arrayX);
- ?>
Copy code
Example 4, php array splitting.
-
- $array = array(1,2,3,4,5,6,7,8,9);
- $arrayX = array_splice($array, 2, 6); / /Get the 2nd element to the 7th element of the array
- print_r($array);
- print_r($arrayX);
- ?>
Copy code
>>>> Articles you may be interested in:
PHP array splitting and array joining
php chunk function split array instance
php mb_chunk_split function supports wide character split
Example of php space-separated text into array
A simple example of splitting a Chinese string into an array in php
Several ways to split Chinese and English strings in php
php split() string splitting function application example
Solution to php splitting GBK Chinese garbled characters
Example of php string splitting function explode
php array merge sample code
Two ways to merge two arrays in PHP
php method to merge arrays according to classification
php array operation example: merging arrays
PHP array merging, appending and connecting methods (array_merge(), array_combine() functions)
Examples of php array merging and recursive merging
PHP array merging example learning
|