This is probably something really simple... but i can't seem to find anything on it.
Is there a way to tell if a string has digits in it?
I am trying to do password checks and make sure that the password has at least 1 digit.
Thanks!
Contains a Digit
Moderator: General Moderators
Off the top of my head I can't think of a function that will check that a string has a numeric character in it (I can only think of alphanumeric or strict numeric checks).
So, I'd prob just opt for a quick regex i.e...
So, I'd prob just opt for a quick regex i.e...
Code: Select all
if (preg_match('/[0-9]+/', $string))
{
// do something
}