Hi guys,
Is there anyway I can process and output a result, evaluating a condition which is given in a string??
ok let me explain,
Initially what happen is all my formulas (conditions) will be entered from the back end of my system. so from the front end if some user select a particular formula the system should be able to grab that data from the database (which is return as a string) and process it and out put only the result to the user.
here is an example what i did:
//backend formula
//------------------------
//formula name : ADD
$formula = '$a + $b';
//front end user select the formula 'ADD'
//------------------------------------------------
//assigning values to $aa and $bb
$aa=5;
$bb=6;
$databaseStr = '$a + $b'; //fetched from the database
eval("\$xx = \"$databaseStr \";");
print $xx;
but the result was,
//out put from above code
5 + 6
I dont want this. What i want is to PHP to assign those variables to $aa and $bb and process it (add them according to this formula) and return the out put. so as for the above formula it should return me 11 not 5 + 6.
Can I do this?
Thanks in advance,
Regards,
niroshan