> How should I proceed? Thanks in advance for any suggestions. Since you are looping through the result already, why not do it this way ..
$combinedArray = array(); for ($i=0;$i<count($myArray);$i++) { $sql = "SELECT study,symbol FROM test WHERE study IN ('$myArray[$i]')"; $result = mysql_query($sql); if(mysql_num_rows($result) > 0) { while ($myrow = mysql_fetch_array($result)) { if (in_array($myrow['study'], $myArray)) $combinedArray[$myrow['study']][] = $myrow['symbol']; } } } You should get an array like this ... array("b2008" => array("A", "B", "C", "D"), "b2005" => array("A", "B", "E")) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php