In JS I used this code:
if(string.match(/[^A-Za-z0-9]+/))
but I don\'t know, how to do it in PHP.
if(preg_match('/^[A-Za-z0-9]+$/i', $string)){ // '/^[A-Z-a-z\d]+$/i' should work also
// $string constains both string and integer
}
The carrot was in the wrong place so it would have search for everything but what is inside the square brackets. When the carrot is outside it searches for what is in the square brackets.