i have two sql queries, and creating two different arrays then merging them using the + operator.. the problem i have is the first array has a count value and the second array has another. i want to add these values but when i merge the arrays one array overwrites the other (as stated in the manual) so the count i get is a count from just the first array and not the combine with the second array.. understand?
here is the example code.
$array1 = array();
$result1 = mysql_query("SELECT pm_read.*, COUNT(*) AS total where blah=blah");
while($users = mysql_fetch_array($result1))
{
$array1[] = $users;
}
$array2 = array();
$result2 = mysql_query("SELECT pm_read.*, COUNT(*) AS total where blah=blah");
while($users = mysql_fetch_array($result2))
{
$array2[] = $users;
}
// merge the arrays
$array = $array1 + $array2;
foreach($array AS $uid => $uname)
{
//...
}
.. but when i use $uname['total'] i get the total from the first array. not the total from both.. how can i combine total from the first array and total from the second array but also merging at the sametime?