libphonenumber\PhoneNumberUtil::getNationalSignificantNumber PHP Method

getNationalSignificantNumber() public method

Gets the national significant number of the a phone number. Note a national significant number doesn't contain a national prefix or any formatting.
public getNationalSignificantNumber ( PhoneNumber $number ) : string
$number PhoneNumber the phone number for which the national significant number is needed
return string the national significant number of the PhoneNumber object passed in
    public function getNationalSignificantNumber(PhoneNumber $number)
    {
        // If leading zero(s) have been set, we prefix this now. Note this is not a national prefix.
        $nationalNumber = '';
        if ($number->isItalianLeadingZero()) {
            $zeros = str_repeat('0', $number->getNumberOfLeadingZeros());
            $nationalNumber .= $zeros;
        }
        $nationalNumber .= $number->getNationalNumber();
        return $nationalNumber;
    }

Usage Example

 /**
  * Returns the description of the geographical area the {@code number} corresponds to. This method
  * distinguishes the case of an invalid prefix and a prefix for which the name is not available in
  * the current language. If the description is not available in the current language an empty
  * string is returned. If no description was found for the provided number, null is returned.
  *
  * @internal param \libphonenumber\PhoneNumber $number the phone number to look up
  * @param \libphonenumber\PhoneNumber $phoneNumber
  * @return string|null bla the description of the geographical area
  */
 public function lookup(PhoneNumber $phoneNumber)
 {
     if (count($this->areaCodeMapStorage) == 0) {
         return null;
     }
     $phonePrefix = $phoneNumber->getCountryCode() . $this->phoneUtil->getNationalSignificantNumber($phoneNumber);
     while (strlen($phonePrefix) > 0) {
         if (array_key_exists($phonePrefix, $this->areaCodeMapStorage)) {
             return $this->areaCodeMapStorage[$phonePrefix];
         }
         $phonePrefix = substr($phonePrefix, 0, -1);
     }
     return null;
 }
All Usage Examples Of libphonenumber\PhoneNumberUtil::getNationalSignificantNumber
PhoneNumberUtil