I want to get values of command tags (GET, FROM, IN, etc.) My command is:
// My command
$_cmd = 'GET a, b FROM p IN a and c="I am from Sarajevo" or d>1 ';
// My parser
if(preg_match_all('/(GET|FROM|IN)\s+([^\s]+)/si',$_cmd, $m))
$cmd = array_combine($m[1], $m[2]);
Output:
Array
(
[GET] => a,
[FROM] => p
[IN] => a
[from] => Sarajevo"
)
I am looking for this output:
Array
(
[GET] => a, b
[FROM] => p
[IN] => a and c="I am from Sarajevo" or d>1
)
As you see, problem is with whitespaces and repeated command tags in strings (like from). So how can I parse this command?
/i-modifier - wouldn't you be able to make sure that you're only countingFROMand notfrom? Would there be a scenario where theINwould involve a string with a uppercasedfrom?