math in PHP

From: Date: Sat, 18 Sep 2004 21:15:14 +0000
Subject: math in PHP
Groups: php.general 
Request: Send a blank email to php-general+get-197126@lists.php.net to get a copy of this message
Hi! I have been trying to make some sort of calculator in PHP, but I have stumbled on a problem... I have been make some kind of dynamical calculator, unlike most I have seen, that had $value1 [math operator] $value2 strict, but a calculator, that can calculate basically anything ( even something like (5*(8-3)+2*(4-1))^3 ), and can be put in as string variable... I have tried things like this: $var = "1+1+1+1"; echo $var + 0; //returns 1 or $var = "1+1+1+1"; echo eval("\$var;"); //returns blank or $var = "1+1+1+1"; echo (int) $var; //returns 1 things like that... Now my question is: is it possible to calculate the value of the string somehow? Thanks. Stormy.

« previous php.general (#197126) next »