Comparison operator ?

wxdqz

New Member
I want to compare two variables, but I want the comparison operator used to also be a variable. The setup would be something like this:

$a = '5';
$b = '10';
$operator = '>';

I have tried the following and neither one works:

if ($a $operator $b) {
// do something
}

if ($a ."$operator". $b) {
// do something
}

Can anyone please offer a solution to this? TIA
 
Back
Top