diff options
author | Andreas Fischer <bantu@phpbb.com> | 2012-06-11 15:22:55 +0200 |
---|---|---|
committer | Andreas Fischer <bantu@phpbb.com> | 2012-06-11 15:46:03 +0200 |
commit | cbff02db4f84c83c62bdd1f7450b8afbf39a5270 (patch) | |
tree | 14faafb86df15b64c767da6458cea05e1a53b52a /phpBB/includes/functions.php | |
parent | 09fb9a9efe048cef102471d1ce79cdeff932776a (diff) | |
download | forums-cbff02db4f84c83c62bdd1f7450b8afbf39a5270.tar forums-cbff02db4f84c83c62bdd1f7450b8afbf39a5270.tar.gz forums-cbff02db4f84c83c62bdd1f7450b8afbf39a5270.tar.bz2 forums-cbff02db4f84c83c62bdd1f7450b8afbf39a5270.tar.xz forums-cbff02db4f84c83c62bdd1f7450b8afbf39a5270.zip |
[ticket/10931] Make to_numeric function globally available.
PHPBB3-10931
Diffstat (limited to 'phpBB/includes/functions.php')
-rw-r--r-- | phpBB/includes/functions.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 95f2cf8d26..ad64471388 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4987,3 +4987,16 @@ function phpbb_pcre_utf8_support() } return $utf8_pcre_properties; } + +/** +* Casts a numeric string $input to an appropriate numeric type (i.e. integer or float) +* +* @param string $input A numeric string. +* +* @return int|float Integer $input if $input fits integer, +* float $input otherwise. +*/ +function phpbb_to_numeric($input) +{ + return ($input > PHP_INT_MAX) ? (float) $input : (int) $input; +} |