Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 7
- 0
- 32
- 47534
- asdf
- 35/gdf
- ../34.
- etc..
- if (preg_match("/^[0-9]$/", $original_stock))
- {
- $error .="Original stock must be numerical.";
- }
- /^d+$/
- /^d+.?d*$/
- #Assuming $original_stock is a single value...
- if (is_int($original_stock)) {
- #Valid, do stuff
- }
- else {
- #Invalid, do stuff
- }
- #Assuming $original_stock is an array...
- $valid = true;
- foreach ($original_stock as $s) {
- if (!is_int($s)) {
- $valid = false;
- break;
- }
- }
- if ($valid) {...}
- else {...}
- /^[0-9]+$/
- /^d+$/
- /^d+(.d{1,2})?/
- if (!preg_match("/^+$/", $original_stock)) {
- // error
- }
- is_int
- /^[0-9]$/
- function validate_int($subject)
- {
- //Pattern is numbers
- //if it matches anything but numbers, we want a fail
- $pattern = '/[^0-9]/';
- $matches = preg_match($pattern, $subject);
- if($matches > 0)
- return false;
- else
- return true;
- }
- if (ctype_digit($x) && $x > 0) {
- // here you go
- }
Add Comment
Please, Sign In to add comment