You are here: Re: Splitting strings, explode? « All PHP « IT news, forums, messages
Re: Splitting strings, explode?

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация