Created
April 14, 2022 15:11
-
-
Save othonet/437b67f655ec5dc80caa9587c4adaff3 to your computer and use it in GitHub Desktop.
PHP - Validate CEP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$valor = '18135-690'; | |
if (preg_match('/[0-9]{5,5}([-]?[0-9]{3})?$/', $valor)): | |
echo 'CEP válido'; | |
else: | |
echo 'CEP inválido'; | |
endif; | |
// Saída CEP válido |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment