Home  >  Article  >  Backend Development  >  PHP gets the regular number of numbers in a string_PHP tutorial

PHP gets the regular number of numbers in a string_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:02:331115browse

filter_sanitize_number_int filter removes all illegal characters in numbers.

This filter allows all numbers as well as +-.
*/

$number="5-2+3pp";

var_dump(filter_var($number, filter_sanitize_number_int));

/*
Verification number: ^[0-9]*$
Verify n-digit number: ^d{n}$
Verify at least n digits: ^d{n,}$
Verify m-n digit number: ^d{m,n}$
Verify numbers starting with zero and non-zero: ^(0|[1-9][0-9]*)$
Verify a positive real number with two decimal places: ^[0-9]+(.[0-9]{2})?$
Verify positive real numbers with 1-3 decimal places: ^[0-9]+(.[0-9]{1,3})?$
Verify non-zero positive integers: ^+?[1-9][0-9]*$
Verify non-zero negative integers: ^-[1-9][0-9]*$
Verify non-negative integer (positive integer + 0) ^d+$
Verify non-positive integers (negative integers + 0) ^((-d+)|(0+))$
Validate characters of length 3: ^.{3}$

For more details, please check: http://www.bkjia.com/phper/php-function/35065.htm
*/


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445374.htmlTechArticlefilter_sanitize_number_int filter removes all illegal characters in numbers. This filter allows all numbers as well as +-. */ $number=5-2+3pp; var_dump(filter_var($number, filter_sanit...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn