Created
June 18, 2020 16:08
-
-
Save zerobugs-oficial/df41876413f1f7740a31dac80843f978 to your computer and use it in GitHub Desktop.
Remover caracteres não numéricos (texto) de uma string com PHP
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 | |
function limpar_texto($str){ | |
return preg_replace("/[^0-9]/", "", $str); | |
} | |
// Exemplo de Utilização | |
echo limpar_texto('Olá 1456Mundo!'); | |
// vai retornar 1456 | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment