I have a database table that stores various type of operators and values that make expressions like
if(mydBVal1 mydBExpression mydBval2)
{
// do something....!
}
Here is my code thats shows and example of what I want to say and the help I require
e.g:
$data['myValue'] = 100;
$data['operator'] = "<";
$data['comparison_value'] = 150
if( $data['myValue'] . $data['operator'] . $data['comparison_value'] )
{
///do something......
}
I want that if condition to be read as if(100 < 150){}, but the if condition expression is not working properly!
any one here know how I can make it work?
I think you want to use the
eval()function.Be very careful about sanitising the data from the database before evaling it though as you could allow users to execute PHP code that you don’t want them to.