phone-number

Formatting Phone Numbers in PHP

帅比萌擦擦* 提交于 2019-12-17 03:51:05
问题 I am working on an SMS app and need to be able to convert the sender's phone number from +11234567890 to 123-456-7890 so it can be compared to records in a MySQL database . The numbers are stored in the latter format for use elsewhere on the site and I would rather not change that format as it would require modifying a lot of code. How would I go about this with PHP? Thanks! 回答1: $data = '+11234567890'; if( preg_match( '/^\+\d(\d{3})(\d{3})(\d{4})$/', $data, $matches ) ) { $result = $matches

Read all contacts' phone numbers in android

拟墨画扇 提交于 2019-12-16 22:40:34
问题 I'm using this code to retrieve all contact names and phone numbers: String[] projection = new String[] { People.NAME, People.NUMBER }; Cursor c = ctx.getContentResolver().query(People.CONTENT_URI, projection, null, null, People.NAME + " ASC"); c.moveToFirst(); int nameCol = c.getColumnIndex(People.NAME); int numCol = c.getColumnIndex(People.NUMBER); int nContacts = c.getCount(); do { // Do something } while(c.moveToNext()); However, this will only return the primary number for each contact,

Read all contacts' phone numbers in android

与世无争的帅哥 提交于 2019-12-16 22:40:08
问题 I'm using this code to retrieve all contact names and phone numbers: String[] projection = new String[] { People.NAME, People.NUMBER }; Cursor c = ctx.getContentResolver().query(People.CONTENT_URI, projection, null, null, People.NAME + " ASC"); c.moveToFirst(); int nameCol = c.getColumnIndex(People.NAME); int numCol = c.getColumnIndex(People.NUMBER); int nContacts = c.getCount(); do { // Do something } while(c.moveToNext()); However, this will only return the primary number for each contact,

TelephonyManager.getLine1Number() failing?

爷,独闯天下 提交于 2019-12-16 20:56:31
问题 I want to get phone number of android device. I use this code: TelephonyManager tm = (TelephonyManager)this.getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE); String phoneNumber= tm.getLine1Number(); On my phone (HTC Wildfire) I can not get phone number - all I get is empty string. If I run code on emulatur, phone number is normally showed. If I go to Settings=>About phone=>Phone identity->Phone number, phone number is "Unknown". Where is the problem? Is something wrong with

TelephonyManager.getLine1Number() failing?

淺唱寂寞╮ 提交于 2019-12-16 20:56:12
问题 I want to get phone number of android device. I use this code: TelephonyManager tm = (TelephonyManager)this.getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE); String phoneNumber= tm.getLine1Number(); On my phone (HTC Wildfire) I can not get phone number - all I get is empty string. If I run code on emulatur, phone number is normally showed. If I go to Settings=>About phone=>Phone identity->Phone number, phone number is "Unknown". Where is the problem? Is something wrong with

Algorithm to determine international calling code from phone number

非 Y 不嫁゛ 提交于 2019-12-14 03:43:51
问题 I'm able to retrieve contact's phone number from the device using Address Book framework on iOS. How can I separate or identify which is country code and which is actual phone number? Is it possible? 回答1: Country codes are a fairly messy topic but standard enough that with some programmer maintenance you can solve it. You can identify a country code by its initial subsequence. Do the following algorithm: Build a simple database - can even store as a flat file and load into a dictionary in

Validating USA cell/mobile phone numbers with regex? [duplicate]

拈花ヽ惹草 提交于 2019-12-13 22:14:14
问题 This question already has an answer here : Regular expression to validate US phone numbers? [duplicate] (1 answer) Closed 11 months ago . I need to write validation to check if a phone number is a valid USA cell / mobile phone number. I have found examples for landlines but not cell / mobile phones. Can anyone point me in the right direction with this? 回答1: you can use Google's phone number handling library. Maybe better than regex. Here: https://github.com/giggsey/libphonenumber-for-php 来源:

How to convert a random telephone number from a number into words from dictionaries and how to select it from a text and convert it in python?

て烟熏妆下的殇ゞ 提交于 2019-12-13 11:36:42
问题 I am trying to convert a random telephone number from a number into words using dictionaries using the following code: dict_1 = {07: 'zero seven'} dict_2 = {2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight'} dict_3 = {0: 'zero', 1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine'} def main(): import re no_tel = raw_input("Enter a phrase: ") mat = re.search('(\d{10})', no_tel) a_no = mat.group(0) first_part = a_no[0:2]

Replace phone prefix of multiple format using php

感情迁移 提交于 2019-12-13 09:55:03
问题 I has an array : $phone_number = array ( 'phone' => '01219104579', 'phone' => '01219104579@abc. 'phone' => '+8401219101219', 'phone' => '01219104579/01219104479', 'phone' => '841219104579@abc.com', 'phone' => 'abcd01219104579@abc.com', 'phone' => 'Hồ2101219104579@abc.com' ); I need to replace all Phone NO prefix (0121 or 121) with new number prefix (072 or 72): $phone_number = array ( 'phone' => '0729104579', 'phone' => '0729104579@abc.com', 'phone' => '+840729101219', 'phone' => '0729104579

Checking through intent if user has certain messaging app installed android

微笑、不失礼 提交于 2019-12-13 07:27:44
问题 I am working with this code which Ragu Swaminathan helped me with on my original post found at: How to show both texting and dialer apps with a single Intent on Android?. final List<Intent> finalIntents = new ArrayList<Intent>(); final Intent textIntent = new Intent(Intent.ACTION_VIEW); textIntent.setType("text/plain"); textIntent.setData(Uri.parse("sms:")); final PackageManager packageManager = getActivity().getPackageManager(); final List<ResolveInfo> listCam = packageManager