i created a search engine on my site using full text search in Postegresql. i added a searchbox in my PHP page in which users can write strings like these:
word1 +word2
word1+word2
word1 -word2
word1-word2
word1 word2
word1 word2
how to convert them to the following strings?
word1&word2
word1&word2
word1&!word2
word1&!word2
word1|word2
word1|word2
i tried several solutions but none works with all cases. The last one i tried is the following:
$user_query_string = trim($_GET['search']);
$final_query_string = str_replace(array('+', ' ', '-'), array('&','|', '&!'), $user_query_string);
Try this:
This will give: