I have a system that follows the concept of information retrieval of Artificial Intelligence. Example:
ovo
// Search all documents that have an egg
not ovo
// Search all documents that do not have an egg.
ovo and óleo
// Search for all documents that have egg and oil
I'm implementing parenthesis handling, but I'm having difficulty. Example:
ovo and (not óleo)
To remove the parentheses I did:
if ($array[0] == '(')
$array = substr($array, 1);
if ($array[strlen($array)-1] == ')')
$array = substr($array, 0, -1);
I have the following functions:
operador_and($array, $array2)
operador_or($array, $array2)
operador_xor($array, $array2)
operador_not($array)
How can I do to select everything inside the parentheses, then do the rest?