On Fri, 13 Jul 2001, Christodoulou Demetris wrote:
> Hi list.
> I have strings that are mathematical expressions. These strings are
> submitted through forms.
> For example a string might be $a="1+cos(0.3)*x".
> Is there a way to convert this string to a mathematical expression that can
> be calculated?
This is possible:
<?php
$x = 2;
$a = '$c = 1 + cos (0.3) * $x;';
eval ($a);
echo $c;
?>
outputs:
2.9106729782512
regards,
Derick
---------------------------------------------------------------------
PHP: Scripting the Web - www.php.net - [EMAIL PROTECTED]
SRM: Site Resource Manager - www.vl-srm.net
---------------------------------------------------------------------
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]