- 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]+';
preg_match_all("/([-+])?($ATOM_REGEX:)?($ATOM_REGEX)/", $query, $match);
print_r($match);