php codeigniter邮政编码搜索! [英] php codeigniter postcode search!

查看:71
本文介绍了php codeigniter邮政编码搜索!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我住在英国,我想在我的网站上实现一个邮政编码搜索框。我有从 http://www.easypeasy.com/guides/article下载的数据库.php?article = 64 。我有一个问题要问,对于这里的大多数专家来说,我相信这很愚蠢。如果我在搜索框中输入邮政编码,该如何对它进行子字符串化?我的意思是,假设我的邮政编码是BS8 1RY,但是数据库中没有BS81RY的邮政编码,但是BS8存在。当我浏览邮政编码数据库时,我发现您有2,3甚至4,5位数的邮政编码。例如,AB10等,有些也像BS8一样也是3位数字。因此,有没有一种标准可以区分邮政编码,然后在sql查询中使用它!

I am based in UK and I want to implement a postcode search box in my website. I have the database downloaded from http://www.easypeasy.com/guides/article.php?article=64. I have a question to ask, which I am sure is very silly for most of the experts here. If I enter a post code in my search box, how should I substring it? What I mean to say is,suppose my postcode is BS8 1RY, but there is no postcode in database as BS81RY, but BS8 is there. When I was going through the database of postcodes I found that you have 2,3 or even 4,5 digits of post code. For example, AB10 etc. and some are of 3 digits too like BS8. So, is there a standard to distinguish the postcodes and then use it in sql query!?

推荐答案

此正则表达式位于英国邮政编码维基百科页面,它应该可以帮助您识别正确的邮政编码:

This regular expression was on the UK postcode wikipedia page, it should help you identify a proper postcode:

(GIR 0AA)|(((A [BL] | B [ABDHLNRSTX]?| C [ABFHMORTVW] | D [ADEGHLNTY] | E [HNX]?| F [KY] | G [LUY]?| H [ADGPRSUX] | I [GMPV] | JE | K [ATWY] | L [ADELNSU]?| M [EKL]?| N [EGNPRW]?| O [LX] | P [AEHLOR] | R [GHM] | S [AEGKLMNOPRSTY]?| T [ADFNQRSW] | UB | W [ADFNRSV] | YO | ZE)[1-9]?[0-9] |(((E | N | NW | SE | SW | W)1 | EC [1-4] | WC [12])[ A-HJKMNPR-Y] |(SW | W)([2-9] | [1-9] [0-9])| EC [1-9] [0-9])[0-9] [ABD -HJLNP-UW-Z] {2})

(GIR 0AA)|(((A[BL]|B[ABDHLNRSTX]?|C[ABFHMORTVW]|D[ADEGHLNTY]|E[HNX]?|F[KY]|G[LUY]?|H[ADGPRSUX]|I[GMPV]|JE|K[ATWY]|L[ADELNSU]?|M[EKL]?|N[EGNPRW]?|O[LX]|P[AEHLOR]|R[GHM]|S[AEGKLMNOPRSTY]?|T[ADFNQRSW]|UB|W[ADFNRSV]|YO|ZE)[1-9]?[0-9]|((E|N|NW|SE|SW|W)1|EC[1-4]|WC[12])[A-HJKMNPR-Y]|(SW|W)([2-9]|[1-9][0-9])|EC[1-9][0-9]) [0-9][ABD-HJLNP-UW-Z]{2})

这篇关于php codeigniter邮政编码搜索!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆