You thought about creating a rights table with callbacks, for example:
$table = array();
$table[] = array(
'name' => 'equals',
'call' => 'check_equals'
);
$table[] = array(
'name' => 'or',
'call' => 'check_or'
);
$myData = array(
true => true,
false => true,
true => false,
true => -1,
)
foreach($myData as $first => $second)
{
foreach($table as $check)
{
echo $check['name'] . call_user_func($check['call'],$first,$second) ? 'good' : 'bad';
}
}
adn, then just create your callbacks like this:
function check_or($f1,$f2)
{
return $f1 || $f2;
}
function check_equals($f1,$f2)
{
return $f1 === $f2;
}
source
share