Hello,
Here are some possiblities. All problems are not thought out here, but maybe the direction will help...
===========
You wrote:
it's easy to seperate words by their spaces and explode them into an array, but how can i get the words combined by " into the same array?
you know, if someone searches for:
president "bill clinton" cigar
Try:
$string = "\"bill clinton\" cigar, monica";
$arrayIn = explode(",", $string);
Gives you the same as:
$arrayCommas = array([0] => "\"bill clinton\" cigar", [1] => " monica");
Then try:
$arrayOut = array();
foreach ($arrayCommas AS $plate1) {
$plate1 = trim($plate1);
if (strpos("\"", $plate1)) {
$arrayQuotes = explode("\"", $plate1);
foreach ($arrayQuotes AS $plate2) {
$plate2 = trim($plate2);
array_push($arrayOut, $plate2);
} //end foreach
} else {
array_push($arrayOut, $plate1);
} //end if
} //end foreach
print_r($arrayOut);
Done:
That may get you somewhere near an array where the "exact phrase" portions are saved. It's a fairly mechanical solution, so there is definitely something more elegant to be done. Note: I'm not completely sure on the argument order for strpos, so check that out.
For the dynamic variable it goes something like:
$variable = "variable" . ++n;
$$variable = "someValue";
For the whitespace replacement around commas try:
$string = str_replace(array(" ,", " , ", ", "), ",", $string);
-or-
$string = ereg_replace("[ ][,]{1}[ ]", ",", $string);
It's 4:30am...time to sleep...
Good luck,
Brandon