A + is a special character in regular expressions. You should escape it with a \, like: -
$keywords1=preg_replace("/\+/"," ",$keywords[1]);
or, more efficiently, avoid the regular expression and use str_replace: -
$keywords1=preg_replace('+',' ',$keywords[1]);
or, assuming you might end up with other encoded characters in your query, you could use: -
$keywords1=urldecode($keywords[1]);
By the way, it's also more efficient to use single quotes rather than double quotes if you don't need to substitute variables inside the string, though it is minute differences.
|