php example code : array_merge function in php - merge multiple arrays
array-merge-example-in-php.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>php example code : array_merge function in php - merge multiple arrays</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Md Iqbal Hosan">
<meta name="title" content="php example code : array_merge function in php - merge multiple arrays">
<meta name="keywords" content="php, example, code, array, function, array_merge">
<meta name="description" content="php example code : array_merge function in php - merge multiple arrays">
</head>
<body>
<h3>php example code : array_merge function in php - merge multiple arrays</h3>
<?php
/*
------------------------------------------------
let us make an array with some keys and values
------------------------------------------------
*/
$myArray1 = array("key1"=>"value1","key2"=>"value2","key3"=>"value3");
echo "<p style='background:#aaa; color:red;'>Output of myArray1</p>";
echo "<pre>";
print_r($myArray1);
echo "</pre>";
/*
----------------------------------------------------
let us make another array with some keys and values
----------------------------------------------------
*/
$myArray2 = array("key5"=>"value5","key6"=>"value6");
echo "<p style='background:#bbb; color:red;'>Output of myArray2</p>";
echo "<pre>";
print_r($myArray2);
echo "</pre>";
/*
--------------------------------------------------------------------------
now merge arrays using array_merge function and save it two another array
--------------------------------------------------------------------------
*/
$finalArray = array();
$finalArray = array_merge($myArray1, $myArray2);
echo "<p style='background:#ccc; color:red;'>Output of finalArray using array_merge function</p>";
echo "<pre>";
print_r($finalArray);
echo "</pre>";
?>
</body>
</html>

No comments:
Post a Comment
leave your comments here..