garfield

[PHP]: Verificar se string é numérica.

Jan 19th, 2012
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.43 KB | None | 0 0
  1. /*
  2.     @Nome: Is_NumericEx,
  3.     @Função: Procura por número em uma string.
  4.     @Créditos: [iPs]SuYaNw.
  5. */
  6.  
  7.  
  8.  
  9. function Is_NumericEx($str)
  10. {
  11.     for($j = 0; $j != count($str); ++$j)
  12.     {
  13.         if($str[$j] == '0' || $str[$j] == '1'  || $str[$j] == '2' || $str[$j] == '3' ||
  14.         $str[$j] == '4' || $str[$j] == '5' || $str[$j] == '6' || $str[$j] == '7' || $str[$j] == '8'  ||
  15.         $str[$j] == '9')
  16.         {
  17.             return true;
  18.         }
  19.     }
  20.     return false;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment