Skip to content

Instantly share code, notes, and snippets.

@temp
Last active August 29, 2015 14:21
Show Gist options
  • Save temp/6fb839272c2785e891a6 to your computer and use it in GitHub Desktop.
Save temp/6fb839272c2785e891a6 to your computer and use it in GitHub Desktop.
$data = array(
'firstname' => array('op' => 'eq', 'value' => 'Stephan'),
'username' => array('op' => 'contains', 'value' => 'swe'),
);
// transform data to expression
$expr = Expr::valid();
foreach ($data as $field => $match) {
if ($match['op'] === 'eq') {
$expr = $expr->andEquals($match['value']);
} elseif ($match['op'] === 'contains') {
$expr = $expr->andContains($match['value']);
}
}
// evaluate criteria ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment