|
Posted by Stefan Rybacki on 08/27/05 13:13
Janwillem Borleffs wrote:
> mike wrote:
>
>>I want the search to be for [ "bob" "frank" ] NOT [ "bob & frank" ]
>>because my search won't match the string. Therefore, I need to be
>>able to break apart the $name variable if it contains more than one
>>persons. I figure it shouldn't be that hard considering I can break
>>about the variables that contain " & " and ", " but so far I'm
>>getting in a bit of a muddle. So I guess my question is, I do I get
>>the above variables into these as easily as possible?
>>
>
>
> function format_query($name) {
> $split = preg_split("/\s*[&,]\s*/", $name);
> return urlencode(implode(" ", $split));
> }
>
> <a href="search.php?q=<?php print format_query($name); ?>">link</a>
Won't help that much. Because you just have all names space separeted. See this example:
$name1="Stefan Rybacki"
$name2="Stefan, Rybacki"
Will lead to the same link which is not correct!
Stefan
Navigation:
[Reply to this message]
|