开发者

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()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜