- print_r: documentation ( source)
- preg_match_all: documentation ( source)
<?php
$query = "-exclude -\"exclude phrase\" \"phrase 1\" keyword +k:v -k2:v2 +\"q kw\":2";
$ATOM_REGEX = '"[^"]+"|[^"\s]+';
"?> atomic group";
preg_match_all("/(?>(?P<flag>[-+])?((?P<key>$ATOM_REGEX):)?(?P<value>$ATOM_REGEX))/", $query, $match, PREG_SET_ORDER);
print_r($match);