I need some help figuring out how to compare the values in two arrays to each other.

(data from db for first query)
cluster_id page_id pagename clustername
----------------------------------------------
1 1 breakingnews newspages
1 3 weather newspages

//put page ids associated with a cluster into an array

for($i = 0; $i < $numrows; $i++) {
$pid= mysql_result($result,$i, page_id);
$pagename =mysql_result($result, $i, pagename);

$pgids= array("$pid" => "$pagename");


(data from db for second query)
pid pagename
---------------------
1 breakingnews
2 pastnews
3 weather

//get all page ids, print checkboxes, preselect checkbox if page id associated with a cluster

while ($x<$numrows){

$mpid=mysql_result($query2,$x, pid);
$mpagename=mysql_result($query2,$x, pagename);

$mpgids= array("$mpid" => "$mpagename");

while (list($mpid, $mpagename) = each ($mpgids)){
print '<input type=checkbox name=page_ids[] value="'.$mpid;

//this where it's not working - compare the values in the arrays to each other
I don't know what to do here, I tried $pgids[$mpid] == $mpgids[$mpid]- none of the checkboxes were automatically checked, but there are two page ids that are in both arrays.

if ($pgids == $mpgids){ print " checked"; }

print '">'.$mpagename;
}

$x++;
}