function phonefield_normalize in Phone Field 7
Helper function.
Normalize phone number. If $link is TRUE: Remove all non-numerics except '+' and '-'. Else: Remove all non-numerics.
Parameters
string $phoneno: The phone number to normalize.
bool $link: If TRUE, make it suitable for a tel:-link.
Return value
string A normalized version of $phoneno.
4 calls to phonefield_normalize()
- phonefield_field_presave in ./
phonefield.module - Implements hook_field_presave().
- phonefield_get_entity_id in ./
phonefield.module - Helper function.
- theme_phonefield_formatter_phonefield_default in ./
phonefield.module - Theme function for 'default' text field formatter.
- theme_phonefield_formatter_phonefield_separate_link in ./
phonefield.module - Theme function for 'separate_link' text field formatter.
File
- ./
phonefield.module, line 595 - Hooks for a module that defines a simple phone number field type.
Code
function phonefield_normalize($phoneno, $link = TRUE) {
return $link ? preg_replace('/[^+-^0-9]/', '', $phoneno) : preg_replace('/\\D/', '', $phoneno);
}