You are here: Re: preg_match/replace to fix a search query « PHP Programming Language « IT news, forums, messages
Re: preg_match/replace to fix a search query

Posted by fsidler@nospam.gmail on 03/16/07 17:17

On Mar 16, 5:19 pm, "fie...@gmail.com" <fie...@gmail.com> wrote:
> I am working on a script to handle a search query. In some instances,
> the query could come through as "isbn:%20#############" (where %20 is
> an encoded space and the colon is optional). Basically I want to
> strip off the ISBN portion and leave just the numbers if that is the
> case.
>
> Orignally I was trying
> $value = $_GET["query"];
> if (preg_match("isbn:?%20", $value))
> {
> $isbn = preg_replace("isbn:?%20", "", $value)}
>
> else
> {
> $isbn = $value
>
> }
>
> Doesn't seem to work though. Any thoughts?

I wouldn't use regex unless really nessessary.
I assume your problem lies with the space character. Usually, the
script transforms encoded url characters back into their original
form. I suggest using a normal space char in the script, and just to
make sure, a str_replace("%20", " ", $string) in the beginning.

 

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

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