I want to make a dayanamic formula creater in which user saves his formula in a varriable and this varriable will hav to show in other dropdown list.
When we select the formula name from the dropdown list there should be all the fields would be displayed which he had given in the formula nd after that just evaluate the string.
How 开发者_开发问答can I do this in PHP?
example- formula name= variable field (+ or any operator)variable field(+or any operator) this formula name would be shown in a other dropdown list nd user select formula from the dropdown list nd there two operator field which we given above should display....
Mohit,
why don't you use eval function? ( very danger function only use if code used in admin side or something like that)
here is simple example of dynamic execution of mathematical formula in PHP.
suppose you have variable $a=25 and $b=15 already bound and you want execute user saved formula [($a+$b)/2].
$a=25;
$b=15;
$formula = "($a+$b)/5";
echo eval($formula); // Result will be 20
精彩评论