All pastes #133031 Raw Edit

Someone

public text v1 · immutable
#133031 ·published 2006-08-15 16:26 UTC
rendered paste body
//Set required Variables
 $RSN = $_GET['rsn'];
 $HSURL = "http://hiscore-web.runescape.com/lang/en/aff/runescape/hiscorepersonal.ws";
 $SkillRegex = "<a href=[^>]+>([^<]+)<\/a><\/td>";
 $DataRegex = "<td align=\"right\">([^>]*)<\/td>";
   
 //Grab hiscores page
 $Hiscores = file_get_contents("$HSURL?user1=$RSN");
 //Fill array with hiscores info
 preg_match_all("/$SkillRegex $DataRegex $DataRegex $DataRegex/i", $Hiscores, $Results); 

 function get($Results,$Skill,$Item) {
  //function to collect certain data. get($Results,"Skill","Rank|Exp|Level")
  //First letter must be capitilised, rest lower case as it it case sensitive.
  $x = 0;
  while ($Results[1][$x]) {
    $CSkill = $Results[1][$x];
    if ($CSkill == $Skill) {
      $Category = $x; 
      $x = 23;
    }
    $x++;
  }
  
  if ($Item == "Rank") $DataItem = "2";
  elseif ($Item == "Level") $DataItem = "3";
  elseif ($Item == "Exp") $DataItem = "4";
   
  return str_replace(",","",$Results[$DataItem][$Category]);
 }