src/PhoneNumberUtil.php
protected static function normalizeHelper($number, array $normalizationReplacements, $removeNonMatches)
    {
        $normalizedNumber = '';
        $strLength = mb_strlen($number, 'UTF-8');
        for ($i = 0; $i < $strLength; $i++) {
            $character = mb_substr($number, $i, 1, 'UTF-8');
            if (isset($normalizationReplacements[mb_strtoupper($character, 'UTF-8')])) {
                $normalizedNumber .= $normalizationReplacements[mb_strtoupper($character, 'UTF-8')];
            } elseif (!$removeNonMatches) {
                $normalizedNumber .= $character;
            }
            // If neither of the above are true, we remove this character.
        }
        return $normalizedNumber;
    }
protected static function normalizeHelper($number, array $normalizationReplacements, $removeNonMatches)
    {
        $normalizedNumber = '';
        $strLength = mb_strlen($number, 'UTF-8');
        for ($i = 0; $i < $strLength; $i++) {
            $character = mb_substr($number, $i, 1, 'UTF-8');
            if (isset($normalizationReplacements[mb_strtoupper($character, 'UTF-8')])) {
                $normalizedNumber .= $normalizationReplacements[mb_strtoupper($character, 'UTF-8')];
            } elseif (!$removeNonMatches) {
                $normalizedNumber .= $character;
            }
            // If neither of the above are true, we remove this character.
        }
        return $normalizedNumber;
    }
protected static function normalizeHelper ( $ number , array $ normalizationReplacements , $ removeNonMatches ) { $ normalizedNumber = '' ; $ strLength = mb_strlen ( $ number , 'UTF-8' ) ; for ( $ i = 0 ; $ i < $ strLength ; $ i ++ ) { $ character = mb_substr ( $ number , $ i , 1 , 'UTF-8' ) ; if ( isset ( $ normalizationReplacements [ mb_strtoupper ( $ character , 'UTF-8' ) ] ) ) { $ normalizedNumber .= $ normalizationReplacements [ mb_strtoupper ( $ character , 'UTF-8' ) ] ; } elseif ( ! $ removeNonMatches ) { $ normalizedNumber .= $ character ; } // If neither of the above are true, we remove this character. } return $ normalizedNumber ; }
Normalizes a string of characters representing a phone number by replacing all characters found
in the accompanying map with the values therein, and stripping all other characters if
removeNonMatches is true.

@param string $number a string of characters representing a phone number
@param array $normalizationReplacements a mapping of characters to what they should be replaced by in
the normalized version of the phone number
@param bool $removeNonMatches indicates whether characters that are not able to be replaced
should be stripped from the number. If this is false, they will be left unchanged in the number.
@return string the normalized string version of the phone number
Normalizes a string of characters representing a phone number by replacing all characters found in the accompanying map with the values therein and stripping all other characters if removeNonMatches is true .