need to get the quoted string and unquoted string in a array
Sample Data
$string='tennissrchkey1 tennissrchkey2 "tennis srch key 3" "tennis srch key 4" "tennis srch key 5"';
Desired Output
Array
(
[0] => tennissrchkey1
[1] => tennissrchkey2
[2] => tennis srch key 3
[3] => tennis srch key 4
[4] => tennis srch key 5
)
So far trying with this but no luck yet
if (preg_match('/"([^"]+)"/', $string, $m)) {
echo '<pre>';
print_r($m);
} else {
//preg_match returns the number of matches found,
//so if here didn't match pattern
}
Any Help is greatly appreciated!!!
Thanks!!!