feha Posted February 15, 2008 Share Posted February 15, 2008 Hi I do have a problem with extracting into array search input keywords ... I use: $keywords = preg_split('/[\s,]+/', $keywords); to split input keywords ... it works o.k. with spaces etc ... I do have a problem with phrase search ... example: me and "my friends" or you and "your friends" Is split o.k. but i do not want to split the word within quotes ... the word within the quotes should not split in to "my .... friends" this makes problems with MySQL query when searching phrases ... the array: Array ( [0] => me [1] => and [2] => "my [3] => friends" [4] => or [5] => you [6] => and [7] => "your [8] => friends" ) I'm not good in RegEx-es any help would be appreciated ... The expression '/"(.*?)"/' can extract the content within double quotes but i can't combine it with preg_split. Quote Link to comment Share on other sites More sharing options...
effigy Posted February 15, 2008 Share Posted February 15, 2008 preg_split('/(".*?")|\s+/', $data, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); Quote Link to comment Share on other sites More sharing options...
feha Posted February 15, 2008 Author Share Posted February 15, 2008 Hello effigy Thank you very much, you saved my day. works great :-) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.