libphonenumber\PhoneNumberUtil::normalizeDigitsOnly PHP Method

normalizeDigitsOnly() public static method

Normalizes a string of characters representing a phone number. This converts wide-ascii and arabic-indic numerals to European numerals, and strips punctuation and alpha characters.
public static normalizeDigitsOnly ( $number ) : string
$number string a string of characters representing a phone number
return string the normalized string version of the phone number
    public static function normalizeDigitsOnly($number)
    {
        return static::normalizeDigits($number, false);
    }

Usage Example

 public function testNormaliseStripAlphaCharacters()
 {
     $inputNumber = "034-56&+a#234";
     $expectedOutput = "03456234";
     $this->assertEquals($expectedOutput, $this->phoneUtil->normalizeDigitsOnly($inputNumber), "Conversion did not correctly remove alpha character");
 }
PhoneNumberUtil