i am using jquery query builder , $rule is array how to loop thround all inner arrays with their proper condition and returns the $rule is true or false?
$rule = array (
'condition' => 'AND',
'rules' => array (
0 => array (
'id' => 'name',
'field' => 'name',
'type' => 'string',
'input' => 'text',
'operator' => 'equal',
'value' => 'bibin',
),
1 => array (
'id' => 'category',
'field' => 'category',
'type' => 'integer',
'input' => 'select',
'operator' => 'not_equal',
'value' => 1,
),
2 => array (
'condition' => 'OR',
'rules' => array (
0 => array (
'id' => 'name',
'field' => 'name',
'type' => 'string',
'input' => 'text',
'operator' => 'equal',
'value' => 'john',
),
1 => array (
'id' => 'category',
'field' => 'category',
'type' => 'integer',
'input' => 'select',
'operator' => 'equal',
'value' => 2,
),
2 => array (
'condition' => 'OR',
'rules' => array (
0 => array (
'id' => 'name',
'field' => 'name',
'type' => 'string',
'input' => 'text',
'operator' => 'equal',
'value' => 'tech',
),
1 => array (
'id' => 'price',
'field' => 'price',
'type' => 'double',
'input' => 'number',
'operator' => 'greater_or_equal',
'value' => 500,
),
),
),
3 => array (
'condition' => 'AND',
'rules' => array (
0 => array (
'id' => 'name',
'field' => 'name',
'type' => 'string',
'input' => 'text',
'operator' => 'equal',
'value' => 'top',
),
1 => array (
'id' => 'category',
'field' => 'category',
'type' => 'integer',
'input' => 'select',
'operator' => 'equal',
'value' => 5,
),
),
),
),
),
3 => array (
'condition' => 'AND',
'rules' => array (
0 => array (
'id' => 'name',
'field' => 'name',
'type' => 'string',
'input' => 'text',
'operator' => 'equal',
'value' => 'vishnu',
),
1 => array (
'id' => 'price',
'field' => 'price',
'type' => 'double',
'input' => 'number',
'operator' => 'less_or_equal',
'value' => 1000,
),
),
),
)
);
I have a nested array called $rule. I want to check the array returns true or false Is any idea to check this array returns true or false? How to iterarte and check with inner arrays?