preg_match numbers negative and positive
I need to fix this preg_match("/^[[0-9开发者_运维百科]{0,4}$/i", $input)
, it also need accept negative values. Thanks
if (preg_match('/^-?[0-9]{1,4}$/', $subject)) {
# Successful match
} else {
# Match attempt failed
}
Like everything else in PHP, there's a dedicated function.
Check out is_numeric()
精彩评论