Page 1 of 1

Merge Array

Posted: Tue May 18, 2010 4:57 am
by nitediver
I have load data from two different table "prod & size", in push.php all data from chosen product push into array.
My question is, how to push the data from "size" along with the "prod"?
I wonder if I merge those two arrays.

Re: Merge Array

Posted: Tue May 18, 2010 6:17 am
by c_cicca
Use the php function "array_merge()"

Example:

Code: Select all

<?php
$array1 = array("color" => "red", 2, 4);
$array2 = array("a", "b", "color" => "green", "shape" => "trapezoid", 4);
$result = array_merge($array1, $array2);
print_r($result);
?>
Output:
Array
(
[color] => green
[0] => 2
[1] => 4
[2] => a
[3] => b
[shape] => trapezoid
[4] => 4
)