You are here

function format_jo_phone_number in Phone 6

Same name and namespace in other branches
  1. 7 include/phone.jo.inc \format_jo_phone_number()

Formatting for Jordanian Phone Numbers.

Parameters

string $phonenumber:

Return value

string Returns a string containting the phone number with some formatting.

File

./phone.jo.inc, line 90
This plugin is contributed by Untitled Web http://untitledstudios.com @author Rashad Majali <rashad.612@gmail.com> http://drupal.org/user/319686

Code

function format_jo_phone_number($phonenumber, $field = FALSE) {
  $phonenumber = trim($phonenumber);
  $regex = "/(^(\\+962|00962|962|0)[-\\s]{0,1}[7]{1}[7-9]{1}[0-9]{7}\$) | (^(\\+962|00962|962|0)[-\\s]{0,1}[2-6][-\\s]{0,1}[0-9]{7}\$)/x";
  preg_match($regex, $phonenumber, $matches);
  $phonenumber = preg_replace('/^(\\+962|00962|962|0)|[-\\s]/', '', $matches[0]);
  return '+962' . $phonenumber;
}