I need to parse a search string for keywords and phrases in php like
line 1: value of "measured response" detect goal "method valuation" study
will give: value,of,measured reponse,detect,goal,method valuation,study
I also need it to work if the string has:
- no phrases in quotation marks,
- any number of phrases is enclosed in quotation marks with any number of keywords outside the quotation marks,
- only phrases in quotation marks,
- keywords separated by spaces.
I tend to use preg_match with the pattern '/(\".*\")/' to get phrases into an array, then remove the phrases from the string, and then finally process the keywords in the array. I just can't get it all together!
I also think of replacing spaces outside quotes with commas. then blast them into an array. if this is the best option, how can I do this with preg_replace ?
Is there a better way to do this? Help! Thank you all very much
Ana ban
source share