Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- @Função: Verificar se uma string é válida
- @Créditos: [iPs]SuYaNw | Garfield
- Modos de verificação:
- Modo 0: Verifica se tem caracteres inválidos,
- Modo 1: Verifica se tem algum número na string.
- */
- function IsValidString($str, $mode)
- {
- switch($mode)
- {
- case 0:
- {
- $MyChars = array("!","@","'","#","$","%","¨","&","*","(",")","-","_","=","+","¹","²","³","[","]","ª",
- "º","°","{","}","?","/",";",":",".",">","<",",","|","§");
- for($i = 0; $i != count($MyChars); ++$i)
- {
- //echo $MyChars[$i]."<br>";
- if(!strstr($str, $MyChars[$i]))
- {
- return true;
- }
- }
- }
- case 1:
- {
- for($j = 0; $j != count($str); ++$j)
- {
- if(is_numeric($str[$j]))
- {
- return false;
- }
- }
- return true;
- }
- }
- return false;
- }
- #Como usar:
- if(IsValidString("Olá Amigos", 0))
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment