random
¶
The random
function returns a random value depending on the supplied
parameter type:
random 関数は、指定されたパラメータ タイプに応じてランダムな値を返します。
- a random item from a sequence;シーケンスからのランダムなアイテム。
- a random character from a string;文字列からのランダムな文字;
- a random integer between 0 and the integer parameter (inclusive).0 から整数パラメーターまでのランダムな整数 (両端を含む)。
- a random integer between the integer parameter (when negative) and 0 (inclusive).integer パラメーター (負の場合) と 0 (0 を含む) の間のランダムな整数。
- a random integer between the first integer and the second integer parameter (inclusive).最初の整数と 2 番目の整数パラメーターの間 (両端を含む) のランダムな整数。
1 2 3 4 5 |
{{ random(['apple', 'orange', 'citrus']) }} {# example output: orange #}
{{ random('ABC') }} {# example output: C #}
{{ random() }} {# example output: 15386094 (works as the native PHP mt_rand function) #}
{{ random(5) }} {# example output: 3 #}
{{ random(50, 100) }} {# example output: 63 #}
|
Arguments ¶
values
: The values値: 値max
: The max value when values is an integermax: 値が整数の場合の最大値