I'm trying to convert an array to condition-like expression string that will be used in the JS Filtrex library. The JS part is irrelevant for this question.
Following is a sample PHP array that I'm trying to work with.
$condition = array(
'and',
array(
array(
'field' => 'show_image',
'compare' => '==',
'value' => 1
),
),
array(
'or',
array(
'field' => 'filter',
'compare' => '!=',
'value' => 1
),
array(
'field' => 'align',
'compare' => '==',
'value' => 'left'
)
)
);
The resulting string will be something like this :
show_image == 1 and ( filter != 1 or align == "left" )
I'm not sold on the array structure so you're free to modify the array as long as it can be extended with more conditions.
Thanks in advance.