Created
September 6, 2019 18:42
-
-
Save Thalesrup/a7456ca109c67382be7dd9c00aef8cb6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| Expressões regulares podem ser usadas para validação de dados, no caso usei palavras declaradas para realizar determinada ação usando uma function de callback como retorno. | |
| <?php | |
| $input = 'and where in select from'; | |
| function verifica($valor) | |
| { | |
| $regex = array('/where/','/from/'); | |
| $regular = preg_replace_callback($regex, create_function('$matches', 'return mb_strtoupper($matches[0]);'), $valor); | |
| echo $regular; | |
| } | |
| echo verifica($input); | |
| echo '<br>'; | |
| ?> | |
| dica de ide online php para teste do code http://www.writephponline.com/ | |
| Obs: utilizei uma array para conter todas as palavras declaradas que irei utilizar para realizar a determinada ação com callback de uma function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment