Multiply - seemed to be so very easy

From: Date: Mon, 11 Nov 2002 09:20:46 +0000
Subject: Multiply - seemed to be so very easy
Groups: php.general 
Request: Send a blank email to php-general+get-123789@lists.php.net to get a copy of this message
Hi. That's my problem: class MYCLASS { var $z = array(); function addOne($PRODUCT_ID,$IL,$PR) { $this->z[$PRODUCT_ID]=array("IL" => $IL, "PR" => $PR); } function myPrice() { $cn = 0.0; reset($this->z); while (list($id,$vals) = each($this->z)) { problem here! -> $cn=$cn + $vals["PR"]*$vals["IL"]; } reset($this->z); return $cn; } } Example to above: $this->z[1] = array ("IL" => 1, "PR" => 634.4); then function myPrice() counts $cn as 634 (not as 634.4)!!! It works like that even when I convert $vals["PR"] and $vals ["IL"] to floats. What's the problem?!?! Thank's for any help :) ----------------------------------------------------------------------- Prawdziwe okazje nie zdarzają się często! Zobacz pełną ofertę! < http://zakupy.wp.pl >

« previous php.general (#123789) next »