It seems the simplest way is just to do it in two regex's.
if (preg_match('/[A-Za-z]/', $myString) && preg_match('/[0-9]/', $myString))
{
echo 'Contains at least one letter and one number';
}
I suppose another way to do it is this below. It says "a letter and then later on at some point a number (or vice versa)". But the one above is easier to read IMO.
if (preg_match('/[A-Za-z].*[0-9]|[0-9].*[A-Za-z]/', $myString))
{
echo 'Contains at least one letter and one number';
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…