aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@phpbb.com>2011-03-05 22:16:50 +0100
committerAndreas Fischer <bantu@phpbb.com>2011-03-05 22:16:50 +0100
commit5ab4dc298327d3a8d51387959d6905c6bb24fd99 (patch)
tree6b560d2512e5fbe20d1d9db5203045d276c874f1 /phpBB/includes
parentafae883619eb7d193b413b5599078a6f47ead408 (diff)
downloadforums-5ab4dc298327d3a8d51387959d6905c6bb24fd99.tar
forums-5ab4dc298327d3a8d51387959d6905c6bb24fd99.tar.gz
forums-5ab4dc298327d3a8d51387959d6905c6bb24fd99.tar.bz2
forums-5ab4dc298327d3a8d51387959d6905c6bb24fd99.tar.xz
forums-5ab4dc298327d3a8d51387959d6905c6bb24fd99.zip
[ticket/10042] Add mt_rand() wrapper which allows swapping $min and $max.
PHPBB3-10042
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/functions.php16
1 files changed, 16 insertions, 0 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 398a02380b..259b3b0481 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -245,6 +245,22 @@ function unique_id($extra = 'c')
}
/**
+* Wrapper for mt_rand() which allows swapping $min and $max parameters.
+*
+* PHP does not allow us to swap the order of the arguments for mt_rand() anymore.
+* (since PHP 5.3.4, see http://bugs.php.net/46587)
+*
+* @param int $min Lowest value to be returned
+* @param int $max Highest value to be returned
+*
+* @return int Random integer between $min and $max (or $max and $min)
+*/
+function phpbb_mt_rand($min, $max)
+{
+ return ($min > $max) ? mt_rand($max, $min) : mt_rand($min, $max);
+}
+
+/**
* Return formatted string for filesizes
*
* @param int $value filesize in bytes