I have a bi dimensional array of array with homogeneous values.
$input = array(
'x' => 100, 'y' => 101, 'type' => 'yes', value => 10
), array(
'x' => 110, 'y' => 101, 'type' => 'no', value => 10
), array(
'x' => 120, 'y' => 102, 'type' => 'yes', value => 99
);
I need to find out a way to write a function to filter values passing a "text" filter as input:
//extract all values when $tye = yes and $value is greater than 10
custom_filter($input, "type = yes and value > 10");
//extract all values when $x is equal to $y
custom_filter($input, "x = y");
//filter all values for x is pair and y is odd
custom_filter($input, "x % 2 = 0 and y % 2 > 0");
function custom_filter($input_array, $condition) {
(...)
}
Is there a way to "translate" $condition parameter from human readable statement to a php conditional statement?