$phoneUtil = PhoneNumberUtil::getInstance();
$number = $phoneUtil->parse("18002530000", "US");
$nationalSignificantNumber = $phoneUtil->getNationalSignificantNumber($number);
$nationalDestinationCodeLength = $phoneUtil->getLengthOfNationalDestinationCode($number);
if ($nationalDestinationCodeLength > 0) {
$nationalDestinationCode = substr($nationalSignificantNumber, 0, $nationalDestinationCodeLength);
$subscriberNumber = substr($nationalSignificantNumber, $nationalDestinationCodeLength);
} else {
$nationalDestinationCode = "";
$subscriberNumber = $nationalSignificantNumber;
}
Refer to the unit tests to see the difference between this function and
{@link #getLengthOfGeographicalAreaCode}.
public getLengthOfNationalDestinationCode ( |
||
$number | the PhoneNumber object for which clients want to know the length of the NDC. | |
리턴 | integer | the length of NDC of the PhoneNumber object passed in. |