Saturday, August 07, 2010

How to evaluate a comparison within a string in php?

Just for an example
$comparison = "2>1";
// $result will be true
$result = eval("return (".$comparison.");");

No comments:

Post a Comment

Do provide your constructive comment. I appreciate that.