문제

I have this xml file - http://gamebattles.majorleaguegaming.com/ps4/call-of-duty-ghosts/team/ngx2-gaming/stats.xml

here which I am outputting the element "winPercentage" as seen below

<?php
$url="http://gamebattles.majorleaguegaming.com/ps4/call-of-duty-ghosts/team/ngx2-gaming/stats.xml";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
$xml = simplexml_load_string($data);
?>
<?php echo $xml->currentStats->winPercentage; ?>

The question is, how can I change the output of 0.667 to 66.7 instead? I assume it would involve multiplying it by 100, but have no idea how to achieve this.

Thank you for your time and help!

도움이 되었습니까?

해결책

Answer is below for anyone else looking for the same thing

Replace:

<?php echo $xml->currentStats->winPercentage; ?>

With

<?php echo (float)$xml->currentStats->winPercentage *100; ?>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top