开发者

preg_match numbers negative and positive

开发者 https://www.devze.com 2023-02-10 13:26 出处:网络
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)) {

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

精彩评论

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