Jan 13th, 2012, 11:22 AM
Ah, sorry. I inverted the logic. Try this:
PHP Code:
if ($comparison == "equal")
{
$fail = false;
// if the field being compared against doesn't exist, we reasonably say that the value won't be the same
if (!array_key_exists($field_to_check, $fields))
$fail = true;
// if the value being passed is an array (e.g. a checkbox / multi-select field), what would be considered
// "equal"? I think as long as the array contains AT LEAST that value, it's fair to pass this test
else if (is_array($fields[$field_to_check]))
{
if (!in_array($field_to_check, $fields))
$fail = true;
}
// lastly, do a straight string test
else if ($fields[$field_to_check] != $value_to_check)
$fail = true;
if ($fail)
{
$satisfies_if_conditions = false;
break;
}
}
else if ($comparison == "not_equal")
{
$fail = true;
// if the field doesn't even exist, we can say they're not equal (i.e. doesn't fail!)
if (!array_key_exists($field_to_check, $fields))
$fail = false;
else if (is_array($fields[$field_to_check]))
{
if (!in_array($field_to_check, $fields))
$fail = false;
}
else if ($fields[$field_to_check] != $value_to_check)
$fail = false;
if ($fail)
{
$satisfies_if_conditions = false;
break;
}
$satisfies_if_conditions = false;
break;
}