EDIT: I got it to work with this; here's what I have so far. But how can I through a loop add keys to the $rank as an array (like $rank[0], $rank[1], $rank[2], ect.) so I can print them and sort the keys. As I have it seems only loop through to have one key $rank[0], and outputs the last one it loops through.
$result = mysql_query("SELECT * FROM smf_members WHERE gspid");
while($row = mysql_fetch_array($result))
{
$gspid = $row['gspid'];
$membername = $row['memberName'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.nintendowifi.com/global/index.jsp?locale=en_US");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt");
$contents = curl_exec($ch);
$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_URL, "http://www.nintendowifi.com/gaminghub/MetroidHuntersLicenseFrame.jsp?gspid=$gspid");
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch2, CURLOPT_COOKIEFILE, "cookies.txt");
$contents2 = curl_exec($ch2);
curl_close($ch2);
preg_match("#<tr><td style=\"text-align: left;\" class=\"left\">Overall Rank</td><td style=\"text-align: right\" class=\"right\">(.*)</td></tr>#", $contents2, $rank);
strip_tags($rank);
}
sort($rank);
foreach ($rank as $element);
{ echo "$element\n"; };
?>