jeudi 28 juillet 2016

PHP Get value then put it to a variable

I have a code to do this:

<?php
$xml=simplexml_load_file("d2ladder.xml") or die("Error: Cannot create object");
$xp1 = 4439;
$xp2 = 8439;
?>

<?php for ($i = 0; $i < 100; $i++) {
<?php $xp = $xml->ladder[12]->char[$i]->experience;
      $xppercent = $xp/$xp2*100; ?>

      <div style="width: <?php echo $xppercent; ?>px">teste</div>
<?php echo $xml->ladder[12]->char[$i]->level; ?>
<?php } ?>

That "$xp2" on the formula need to be set by the $xml->ladder[12]->char[$i]->level

if level = 1 then calculate with $xp1 if level = 2 calculate with $xp2 and goes, I've got 99 fixed xps that varies level 1-99 to calculate in that way

There's a simple way to solve this? thanks

Aucun commentaire:

Enregistrer un commentaire