View Single Post
  #6 (permalink)  
Old 04-18-2008, 03:22 AM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,162
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Re: Operations in PHP

Merging two or more arrays

Using an built-in function array_merge() we can merge two or more arrays to form a single array. The values from the second array are appended at the end of first array and so on. So, if three arrays are to be merged, elements from third will be appended at the end of second array and then it will be appended at the end of the first array. Take a look at this syntax and example:
array_merge ( array array1 [, array array2 [, array ...]] )

PHP Code:
<?
$first_array 
= array(1,2);
$second_array = array(3,4);
$third_array = array(5,6);

$merged_array array_merge($first_array,$second_array,$third_array);
print_r($merged_array);
//Output: Array 
//          ( [0] => 1 
//            [1] => 2 
//            [2] => 3 
//            [3] => 4 
//            [4] => 5 
//            [5] => 6 
//          ) 
?>
__________________
With,
J. Jeyaseelan

Everything Possible
Reply With Quote