Salvis Posted February 28, 2010 Share Posted February 28, 2010 I have code: <?php $_GET["price"]="3.13"; $_GET["currency"]="EUR"; if($_GET['currency']!="LVL"){ $bank=simplexml_load_file('http://valutas.info/xml/'.$_GET["currency"]); foreach ($bank->item->rates as $item) echo "Kurss: ".$item->sellInCash."<br />"; echo "Cena: ".$_GET['price']."<br />"; $kaka=$_GET['price']*$item->sellInCash; echo "Reizinasana: ".$kaka."<br />"; $tests1="0.7028000000000"; echo "Tests: ".$_GET["price"]*$tests1."<br />"; } } ?> I noticed that $_GET['price']*$item->sellInCash gives out 0 but $_GET["price"]*$tests1 returns all correct. Why? Where is mistake? Link to comment https://forums.phpfreaks.com/topic/193659-php-not-multiply/ Share on other sites More sharing options...
Daniel0 Posted February 28, 2010 Share Posted February 28, 2010 I'd be inclined to believe that $item->sellInCash contains an incorrect value, or rather something that is 0 when cast to int. Link to comment https://forums.phpfreaks.com/topic/193659-php-not-multiply/#findComment-1019365 Share on other sites More sharing options...
Mchl Posted February 28, 2010 Share Posted February 28, 2010 And to check what's in there: var_dump($item->sellInCash); Link to comment https://forums.phpfreaks.com/topic/193659-php-not-multiply/#findComment-1019366 Share on other sites More sharing options...
Salvis Posted February 28, 2010 Author Share Posted February 28, 2010 var_dump($item->sellInCash); returns: object(SimpleXMLElement)#5 (1) { [0]=> string(5) "0.708" } Link to comment https://forums.phpfreaks.com/topic/193659-php-not-multiply/#findComment-1019380 Share on other sites More sharing options...
Mchl Posted February 28, 2010 Share Posted February 28, 2010 How about var_dump($item->sellInCash[0]); Link to comment https://forums.phpfreaks.com/topic/193659-php-not-multiply/#findComment-1019527 Share on other sites More sharing options...
Salvis Posted March 1, 2010 Author Share Posted March 1, 2010 If i use $kaka=$_GET['price']*(double)$item->sellInCash; on line #9, it works! Thanks all for helping. Link to comment https://forums.phpfreaks.com/topic/193659-php-not-multiply/#findComment-1019743 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.