Mathmatical formula

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have an application that allows the users to input a formula:
(Width*Height)/144

This formula gets updated with a part's specific width & height and
actually returns:

(36.00000*58.00000)/144

I use preg_replace to replace Width and Height with values from the
following array:

[Width] => 36.00000
[Height] => 58.00000

How can I get the resulting formula to actually calculate?
Simplified version of my code:

$partFormula = '(Width*Height)/144';
$prof = array('Width'=>36,'Height'=>58);

$find = array();
$replace = array();

foreach($prof AS $key => $val){
	array_push($find,"[$key]");
	array_push($replace,$val);				
}
return preg_replace($find,$replace,$partFormula);
//returns (36.00000*58.00000)/144

eval() doesn't seem to do much for me (parse error, unexpected $end).

Thanks,
Mike

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux