An easy question to ask, hope not to stupid.
$var=0;
$condition="$var!=0";
if($condition) {
# do something #
}
else {
# do something else #
}
Obviously the code up there doesn't work as intended. Is there a nice way to obtain an if-condition from a string? Or do I have to parse the string in some disturbing way?
EDIT I didn't explain myself very well. The fact is that the string could contain any possible condition you can immagine es:
- $var > 0
- $var < 0
- $var == 0
- etc
I read this condition from an xml file as a string, so I don't know what I will find.