FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » preg_match() oddities and question
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: preg_match() oddities and question [message #176121 is a reply to message #176108] Thu, 24 November 2011 12:55 Go to previous messageGo to previous message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma:
Senior Member
On Thu, 24 Nov 2011 08:20:45 +0100, Sandman wrote:

> Well, I have been doing this for about ten years now, and recived tons
> of feedback from my clients on things like this. When I say it's
> inconvenient for the end user, it's not something I make up on the spot
> to be obnoxious.

It's a point that a lot of website UI designers overlook - what we think
is the best and most obvious layout, and even "the way everyone does it",
isn't always what the website user finds most user friendly.

As to the OPs problem, perhaps it needs a different approach:

Presumably for any given city you can obtain a list of valid streets?

Why not:

foreach ($street_name in $streets_of_city) {
if (($street_start = strpos($address, $street_name)) !== false) {
foreach ($district_name in $districts_of_city) {
if (($district_start = strpos($address, $district_name,
$street_start)) !== false) {
break;
}
}
break;
}
}

You may need to allow for "district creep" and will need to allow for
streets crossing district boundaries.

Another option, and one that is becoming popular in some areas, might be
to allow entry of the postcode, and then generate a drop down list,
perhaps populated using an XMLHttpRequest, of addresses matching the
postcode - this would require access to a copy of the relevant postcode
database which might involve some cost, and of course you need to
implement a mechanism for handling updates to that database.

Possibly a similar sort of approach, based on a select menu for district,
then a select menu for street names, and then a text entry field for
"apartment number, building name and / or number, or house number as
appropriate".

I don't think you're ever going to parse a single line address entry with
regex, because there are too many different formats that might get thrown
at you. You either need to get the data in a different format, or find a
different method of processing the data that you are getting.

Rgds

Denis McMahon
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Amazing Website!!!
Next Topic: session handler auto log out
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 14:27:29 GMT 2024

Total time taken to generate the page: 0.04358 seconds