Alphabetic equivalent of PHP is_numeric

前端 未结 4 1834
孤城傲影
孤城傲影 2021-01-21 05:35

I am looking for a function that would be the alphabetic equivalent of is_numeric. It would return true if there are only letters in the string and false otherwise. Does a bui

相关标签:
4条回答
  • 2021-01-21 06:00

    I would have used preg_match. But that's because I'd never heard of ctype_alpha().

    if(!preg_match("/[^a-zA-Z]/", $teststring)) {
        echo "There are only letters in this string";
    } else {
        echo "There are non-letters in this string";
    }
    
    0 讨论(0)
  • 2021-01-21 06:06

    !is_numeric((float)$variableToBeChecked); also preg_match('#^[a-z]+$#i',$variableToBeChecked); // for one or more letter character

    0 讨论(0)
  • 2021-01-21 06:17

    If you're strictly looking for the opposite of is_numeric(), wouldn't !is_numeric() do the job for you? Or am I misunderstanding the question?

    0 讨论(0)
  • 2021-01-21 06:24

    You want ctype_alpha()

    0 讨论(0)
提交回复
热议问题