ini_set("user_agent","GameSpyHTTP/1.0");
$info = "per*,cmb*,twsc,cpcp,cacp,dfcp,kila,heal,rviv,rsup,rpar,tgte,dkas,dsab,cdsc,rank,cmsc,kick,kill,deth,suic,ospm,klpm,klpr,dtpr,bksk,wdsk,bbrs,tcdr,ban,dtpm,lbtl,osaa,vrk,tsql,tsqm,tlwf,mvks,vmks,mvn*,vmr*,fkit,fmap,fveh,fwea,wtm-,wkl-,wdt-,wac-,wkd-,vtm-,vkl-,vdt-,vkd-,vkr-,atm-,awn-,alo-,abr-,ktm-,kkl-,kdt-,kkd-";
$pid = '43595724';
$data = file("http://bf2web.gamespy.com/ASP/getplayerinfo.aspx?pid=".$pid."&info=".$info);
$stats = array_combine(explode("\t", $data[3]), explode("\t", $data[4]));
printf("%s has %s kills and %s deaths and a score of %s", $stats['nick'], $stats['kill'], $stats['deth'], $stats['scor']);
Note that if you’re not using PHP5, you’ll need to add the following
drop-in replacement for the “array_combine” function:
It’s also important to note that while at the time of writing this, this
method of retrieving stats works, EA, DICE and GameSpy are supposedly
working on a new XML-based stats system for BF2.
For info on what to do with the stats, and what all the columns etc.
mean, check out the BF2 Technical
Wiki.