I am looking for a function that will be the literal equivalent of is_numeric. It will return true if the string contains only letters, and false otherwise. Is there a built-in function in PHP?
Do you want to ctype_alpha()
ctype_alpha()
If you are strictly looking for the opposite is_numeric(), would not do the !is_numeric()job for you? Or do I not understand the question?
is_numeric()
!is_numeric()
I would use preg_match. But that is because I 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"; }
!is_numeric((float)$variableToBeChecked); also preg_match('#^[a-z]+$#i',$variableToBeChecked); // for one or more letter character
!is_numeric((float)$variableToBeChecked);
preg_match('#^[a-z]+$#i',$variableToBeChecked); // for one or more letter character
Source: https://habr.com/ru/post/1734182/More articles:How to dynamically read RSS - javascriptDirections using Postgis and pgRouting - postgresqlMemory problems dompdf - phpCreating a (threaded) game server in C ++ / WinSock - c ++Resize list contents to fit list sizes - resizeWhere to put methods that make simple date formatting - ruby | fooobar.comHow to disable keyboard shortcuts for jQuery date selector? - jquery-uiDoes an iframe really affect page load time? Why not? - iframeNon-recursive use of a mutex - c ++Нужна помощь, возвращающаяся в приложение BlackBerry из браузераSession - javaAll Articles