PHP电话号码解析器 [英] PHP phone number parser
问题描述
为UK&仅爱尔兰,但可能会扩展到其他国家。我们已经构建了一个API,我正在尝试确定A)如何存储电话号码B)如何编写解析器以了解所有输入和比较格式。
Building an application for UK & Ireland only but potentially it might extend to other countries. We have built an API and I'm trying to decided how A) to store phone numbers B) how to write a parser to understand all formats for entry and comparision.
eg
假设用户在爱尔兰,他们以以下格式添加电话号码
Say a user is in Ireland they add a phone number in these formats
0871231234
0871231234
087 123 1234
087 123 1234
087-1231234
087-1231234
+353871231234
+353871231234
或以任何其他有效的方式写数字的组合。我们希望允许这样做,以便可以以一致的方式将新数字添加到我们的数据库中
Or any other combination of writing a number a valid way. We want to allow for this so a new number can be added to our database in a consistent way
因此,上述所有数字都可能存储为00353871231234
So all the numbers above potentially would be stored as 00353871231234
问题是我也需要对所有英国进行解析。
The problem is I will need to do parsing for all uk as well. Are there any classes out there that can help with this process?
推荐答案
尝试 http://www.braemoor.co.uk/software/telnumbers.shtml
这篇关于PHP电话号码解析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!