Created
September 6, 2019 18:42
-
-
Save Thalesrup/a7456ca109c67382be7dd9c00aef8cb6 to your computer and use it in GitHub Desktop.
Revisions
-
Thalesrup created this gist
Sep 6, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ 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