Reputation: 313
i have a example.xml file and its implement in php for getting value like from this code
<?php
$xml=simplexml_load_file(example.xml);
$xmlbid=$xml->RESULTS->LISTING->value;
?>
this code working fine like when i enter echo $xmlbid
it return me 0.002
value
this is value in xml file its fine.
but problem is when i multiply some value with $xmlbid and its save to another variable and then echo this variable its return me 0 why
like this
$mul=$xmlbid*0.7;
its return 0 why please help me solve this
Upvotes: 0
Views: 54
Reputation: 174
are you sure it's in the correct format, using the right decimal separator?
you can try this:
<?php
$locale = localeconv();
$xml=simplexml_load_file(example.xml);
$xmlbid=$xml->RESULTS->LISTING->value;
$xmlbid = (float)str_replace(',', '.', str_replace($locale['decimal_point'], '.', $xmlbid));
$mul=$xmlbid*0.7;
?>
it will replace the decimal separator to a point and also the comma, just to make sure :) actually one of these is enough probably, it depends on the input.
Upvotes: 1