reference/array/functions/array-rand.xml
4a1dedc24b1e085f298ab1d5dadefe306373691b
...
...
@@ -27,6 +27,7 @@
27
27
<listitem>
28
28
<para>
29
29
The input array.
30
+
Cannot be empty.
30
31
</para>
31
32
</listitem>
32
33
</varlistentry>
...
...
@@ -35,6 +36,7 @@
35
36
<listitem>
36
37
<para>
37
38
Specifies how many entries should be picked.
39
+
Must be greater than zero, and less than or equal to the length of <parameter>array</parameter>
38
40
</para>
39
41
</listitem>
40
42
</varlistentry>
...
...
@@ -49,11 +51,17 @@
49
51
entries is returned. This is done so that random keys can be picked
50
52
from the array as well as random values. If multiple keys are returned,
51
53
they will be returned in the order they were present in the original array.
52
-
Trying to pick more elements
53
-
than there are in the array will result in an
54
-
<constant>E_WARNING</constant> level error, and NULL will be returned.
55
54
</para>
56
55
</refsect1>
56
+

57
+
<refsect1 role="errors">
58
+
&reftitle.errors;
59
+
<para>
60
+
Throws a <classname>ValueError</classname> if <parameter>array</parameter> is empty,
61
+
or if <parameter>num</parameter> is out of range.
62
+
</para>
63
+
</refsect1>
64
+

57
65
<refsect1 role="changelog">
58
66
&reftitle.changelog;
59
67
<para>
...
...
@@ -67,6 +75,22 @@
67
75
</thead>
68
76
<tbody>
69
77
<row>
78
+
<entry>8.0.0</entry>
79
+
<entry>
80
+
<function>array_rand</function> now throws a <classname>ValueError</classname>
81
+
if <parameter>num</parameter> is out of range; previously an
82
+
<constant>E_WARNING</constant> was raised, and the function returned &null;.
83
+
</entry>
84
+
</row>
85
+
<row>
86
+
<entry>8.0.0</entry>
87
+
<entry>
88
+
<function>array_rand</function> now throws a <classname>ValueError</classname>
89
+
if <parameter>array</parameter> is empty; previously an
90
+
<constant>E_WARNING</constant> was raised, and the function returned &null;.
91
+
</entry>
92
+
</row>
93
+
<row>
70
94
<entry>7.1.0</entry>
71
95
<entry>
72
96
The internal randomization algorithm <link linkend="migration71.incompatible.rand-srand-aliases">has been changed</link> to use the <link xlink:href="&url.mersenne;">Mersenne Twister</link> Random Number Generator instead of the libc rand function.
73
97