try changing the plusses to %20 thats code for space in url strings
I have the following code:
echo $ref_url.'<br>';
echo $keywords[1];
if (isset($keywords[1]) and ($keywords[1]!="") and ($keywords[1]!=" "))
{
$keywords1=preg_replace("/+/"," ",$keywords[1]);
}
echo $keywords;
Which produces the following:
http://localhost/hvi/viewvilla.php?h...lla+rome&meta=
holiday+villa+rome
Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in c:\program files\apache group\apache\htdocs\hvi\logger.inc on line 91
After - holiday+villa+rome
Any idea why my +'s aren't changing to spaces??
NM.
Holiday Villa In<br>
<font size=2>If it moves, kick it. If it doesn't move, kick it till it moves and hen kick it because it moved</font>
try changing the plusses to %20 thats code for space in url strings
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.
Thanks for all the comments, worked a treat!
NM.
P.S. I also use single quote normally where possible but they always creep in places![]()
Holiday Villa In<br>
<font size=2>If it moves, kick it. If it doesn't move, kick it till it moves and hen kick it because it moved</font>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks