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

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
SimpleXML (Zend_Config_Xml actually) and foreach : which tag am I iterating?

Categories

HOME
java
vim
client
wso2
gerrit
bookshelf.js
echarts
wamp
fancybox
flyway4
applepay
vifm
dax
google-apps-marketplace
visual-studio-2005
msp430
clojurescript
alpine
visual-composer
dbext
reverse-proxy
scriptcs
jquery-ajaxq
orleans
chromium-embedded
lcd
rundeck
django-storage
bootstrap-duallistbox
tooltipster
opentype
tinymce-4
semantic-versioning
scorm2004
calibre
lxd
hybridauth
phpfreechat
atl
y86
neuroscience
splice
mesos-chronos
gzipstream
firebase-admin
.net-4.6.2
sencha-touch-2.3
skeleton-css-boilerplate
long-polling
flickr-api
osx-mavericks
network-flow
chain-builder
idisposable
google-perftools
sqlbulkcopy
yt-project
setuptools
probability-density
fody
pcf
py2app
mongocsharpdriver
nsviewcontroller
ubuntu-10.04
unity-networking
ruby-2.2
tmuxinator
jqgrid-formatter
rgeo
tableau-online
event-bubbling
graph-drawing
sankey-diagram
key-management
graph-api-explorer
clipperlib
jsapi
knuth
tt-news
cctv
asp.net-web-api-odata
html-helper
kgdb
mbr
fmod
pyhdf
oam
ruby-datamapper
dataadapter
qt-faststart
mylyn
specification-pattern
venn-diagram
javaspaces
online-compilation
netbeans-6.9
punbb
custom-backend
whoosh
gwt-ext
xmlspy
suppress
exchange-server-2003
swing-app-framework
temporal-database
anti-piracy
sustainable-pace

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App