simplexml


SimpleXML changing parsed decimals


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; ?>

Related Links

SimpleXMLElement::__construct(): Entity: line 1: parser error : Start tag expected, '<' not found
Add xml attribute documentname
Pick shortest route with simpleXML
SimpleXML extract text between two tags
XML Node outside parent item
SimpleXMLElement cannot get the output
SimpleXML changing parsed decimals
can't navigate SimpleXMLElement data
PHP SimpleXML Load File with Null elements
Iterating through and editing a SimpleXML object by reference in PHP
Simplexml Insert into sub element
warning: simplexml_load_file(): I/O warning : failed to load external entity drupal [closed]
What's wrong with this code? SimpleXMLElement [closed]
Get children attributes using simplexml
Select attribute in simplexml
Save formatted xml

Categories

HOME
vbscript
cookies
fluentd
homebrew
lodash
xmpp
spring-jdbc
leon
packages
webpack-2
dacpac
postgres-xl
dtrace
dynamics-crm-online
systemc
facebook-page
angular-ui
reactcsstransitiongroup
solaris-10
accessor
chromium-embedded
zurb-foundation-6
shopware
numerical-methods
pingfederate
maquette
unboundid
grails-3.1
wpf-controls
mixture-model
xenforo
reportingservices-2005
jvm-languages
isbn
wptoolkit
logfiles
fault
promela
carrot
windows-mobile-6.5
spring-android
fody
bstr
pagedlist
python-stackless
pagerank
ipconfig
wapiti
phpcas
simple-framework
iis-arr
quicklisp
sframe
0xdbe
cisco-ios
angularjs-ng-click
android-nested-fragment
project-planning
wp-query
ruby-datamapper
eclipse-memory-analyzer
buster.js
flashvars
specification-pattern
google-email-migration
onsubmit
online-compilation
xdomainrequest
datareader
wise
gin
getresponsestream
memory-size
kdbg
exchange-server-2003
xetex
port-number
mediarss
paul-graham
rtml

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App