I'm trying to output a value from xml this is what I do -
<?php
echo $responseTemp->Items->Item->CustomerReviews->AverageRating;
?>
This outputs 4.5, but when I change it to the code below it displays as 8. Why isn't it displaying as 9? Thanks.
<?php
echo $responseTemp->Items->Item->CustomerReviews->AverageRating*2;
?>
Try casting the value to a numerical value first.
$num = (double) $responseTemp->Items->Item->CustomerReviews->AverageRating;
echo $num * 2;
See Type Juggling and String Conversion to Numbers on the PHP website for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With