array_merge() function is used to merge two or more arrays.
Parameters Description:
array1 : Required. Specifies an array.
array2 : Optional. Specifies an array.
array3 : Optional. Specifies an array.
Tip : You can assign one array to the function, or as many as you like.
Note : If you assign one array to the array_merge() function, and the keys are integers, the function returns a new array with integer keys starting at 0.
Syntax: array_merge(array1,array2,array3...)
Parameters Description:
array1 : Required. Specifies an array.
array2 : Optional. Specifies an array.
array3 : Optional. Specifies an array.
Tip : You can assign one array to the function, or as many as you like.
Note : If you assign one array to the array_merge() function, and the keys are integers, the function returns a new array with integer keys starting at 0.
Example:
<?php
$daysarr1 = array( "a"=>"Sunday","b"=>"Monday" );
$daysarr2 = array( "c"=>"Tuesday","b"=>"Thursday");
print_r( array_merge($daysarr1,$daysarr2) );
$daysarr3 = array( 3=>"Monday",4=>"Sunday" );
echo "<br />"."using only one parameter";
print_r( array_merge($daysarr3) );
?>
O/P:
Array (
[a] => Monday
[b] => Thursday
[c] => Tuesday
)
using only one parameter
Array (
[0] => Monday
[1] => Sunday
)
0 comments:
Post a Comment