Logo

Programming-Idioms

History of Idiom 137 > diff from v22 to v23

Edit summary for version 23 by ricardo_sdl:
New PHP implementation by user [ricardo_sdl]

Version 22

2018-08-18, 21:34:50

Version 23

2018-08-29, 14:51:47

Idiom #137 Check if string contains only digits

Set boolean b to true if string s contains only characters in range '0'..'9', false otherwise.

Idiom #137 Check if string contains only digits

Set boolean b to true if string s contains only characters in range '0'..'9', false otherwise.

Code
$b = preg_match('/\D/', $s) !== 1;
Doc URL
https://secure.php.net/manual/en/function.preg-match.php
Demo URL
https://3v4l.org/8iXMO