If I misunderstood the intval part of your post, than the [proposed already]
is_numeric solutions are the way to go. is_numeric will, however, unlike the
conversion functions, return false if there's anything but a number in the
string, so, i.e., is_numeric ("10a1") will return false, but intval ("10a1")
will give "10".