function isPhoneNumber($phone) { $pattern = "/^\+1-\d{3}-\d{3}-\d{4}$/"; return preg_match($pattern, $phone); } if (isPhoneNumber("+1-123-456-7890")) { echo "Valid phone number"; } else { echo "Invalid phone number"; }
function isPhoneNumber($phone) { $pattern = "/^\(\d{3}\) \d{3}-\d{4}$/"; return preg_match($pattern, $phone); } if (isPhoneNumber("(123) 456-7890")) { echo "Valid phone number"; } else { echo "Invalid phone number"; }To determine the package library used for validation, we can check if the function uses any third-party libraries or if it is a built-in function of PHP. If it uses a third-party library, we need to check the documentation or the composer.json file to determine the package library. If it is a built-in function, we can check the PHP manual to see which version the function was introduced in.