Debt Consolidation - Find jobs - Prefessional Book Reviews - Free Articles Directory About Cancer - Debt Consolidation

PDA

View Full Version : How can I change the "+" in the search string?


dalv
Jan 4th 2006, 5:39 pm
Hi guys,

Do you know how I can change the "+" to "-" in the search string (osCommerce).

Example:

http://example.com/search_result.php?keywords=asd+asd

should look:

http://example.com/search_result.php?keywords=asd-asd

How can I do that?

I think there are two functions that could be related to the problem...but I am not a programmer, so I need help:

function tep_sanitize_string($string) {
$string = ereg_replace(' +', ' ', trim($string));

return preg_replace("/[<>]/", '_', $string);
}


// Break up $search_str on whitespace; quoted string will be reconstructed later
$pieces = split('[[:space:]]+', $search_str);
$objects = array();
$tmpstring = '';
$flag = '';

for ($k=0; $k<count($pieces); $k++) {
while (substr($pieces[$k], 0, 1) == '(') {
$objects[] = '(';
if (strlen($pieces[$k]) > 1) {
$pieces[$k] = substr($pieces[$k], 1);
} else {
$pieces[$k] = '';
}
}

$post_objects = array();

while (substr($pieces[$k], -1) == ')') {
$post_objects[] = ')';
if (strlen($pieces[$k]) > 1) {
$pieces[$k] = substr($pieces[$k], 0, -1);
} else {
$pieces[$k] = '';
}
}

cytech
Jan 6th 2006, 8:22 am
Hey,

Browsers normaly make added keywords with a "+" symbol.

So you would need to do this when the user submits the form, you can use php but might be quicker to just use a small javascript function.

If you can post the "search form" I can do it for ya.

ctdp
Jan 6th 2006, 2:20 pm
If you use:

$new_string=str_replace("+","-",$QUERY_STRING);

Would creata the string "keywords=asd-asd". Using either the str_replace function or the ereg_replace function works. The ereg_replace function is the POSIX compliant version of the function.

dalv
Jan 7th 2006, 8:19 am
$new_string=str_replace("+","-",$QUERY_STRING);



Thanks, guys!

ctdp, that did the trick!