changed it so the associative arrays contains another arrays: the first elements are the proflvl, the other is the hits
Code
function readxml($charid) {
$xml = 'http://ladderslasher.d2jsp.org/xmlChar.php?i='.$charid;
$test = file($xml);
if(count($test)>1) $data = simplexml_load_file($xml);
else return false;
$carr = array('None', 'Fighter', 'Barbarian', 'Rogue', 'Magician', 'Guardian', 'Samurai', 'Paladin', 'Monk', 'Ninja', 'Warlock', 'Headhunter', 'Alchemist');
$pwarr = array('sword' => array(0, 0),
'club' => array(0, 0),
'axe' => array(0, 0),
'dagger' => array(0, 0),
'staff' => array(0, 0),
'longsword' => array(0, 0),
'warhammer' => array(0, 0),
'battleaxe' => array(0, 0),
'spear' => array(0, 0),
'polearm' => array(0, 0)
);
$pcarr = array('ice' => array(0, 0),
'fire' => array(0, 0),
'light' => array(0, 0),
'wind' => array(0, 0),
'earth' => array(0, 0),
'wild' => array(0, 0),
'heal' => array(0, 0),
'focused' => array(0, 0),
);
$psarr = array('fish' => array(0, 0),
'cook' => array(0, 0),
'glyph' => array(0, 0),
'mute' => array(0, 0),
);
$charr = array();
$exp = $data->exp;
$exp = (int)$exp;
$cid = $data->classid;
$cid = (int)$cid;
$pw = $data->wprof;
$pc = $data->cprof;
$ps = $data->sprof;
$w = explode(";", $pw);
$c = explode(";", $pc);
$s = explode(";", $ps);
for($i=0;$i<count($w);$i++) {
$in = explode(",", $w[$i]);
$f=0;
foreach($pwarr as $key => $value) {
if($in[0]==$f) {
$pwarr[$key][0] = (int)$in[1];
$pwarr[$key][1] = (int)$in[2];
}
$f++;
}
}
for($i=0;$i<count($c);$i++) {
$in = explode(",", $c[$i]);
$f=0;
foreach($pcarr as $key => $value) {
if($in[0]==$f) {
$pcarr[$key][0] = (int)$in[1];
$pcarr[$key][1] = (int)$in[2];
}
$f++;
}
}
for($i=0;$i<count($s);$i++) {
$in = explode(",", $s[$i]);
$f=0;
foreach($psarr as $key => $value) {
if($in[0]==$f) {
$psarr[$key][0] = (int)$in[1];
$psarr[$key][1] = (int)$in[2];
}
$f++;
}
}
$charr['name'] = $data->name;
$charr['core'] = $data->core;
$charr['lvl'] = $data->level;
$charr['kil'] = $data->kills;
$charr['dea'] = $data->deaths;
$charr['lac'] = $data->lastaction;
$charr['str'] = $data->strength;
$charr['dex'] = $data->dexterity;
$charr['vit'] = $data->vitality;
$charr['int'] = $data->intelligence;
$charr['hpm'] = $data->hpmax;
$charr['mpm'] = $data->mpmax;
$charr['mqa'] = $data->mqattempts;
$charr['mqp'] = $data->mqpasses;
$charr['class'] = $carr[$cid];
$charr['exp'] = $exp;
$charr['w'] = $pwarr;
$charr['c'] = $pcarr;
$charr['s'] = $psarr;
return $charr;
}
useage:
Code
$char = readxml(112562);
echo $char['s']['mute'][0]; // the skill level
echo $char['s']['mute'][1]; // the hits made
echo $char['class']; // the class (the same as before)
This post was edited by dunaicapa on Jul 9 2009 03:28am