random
random¶New in version 1.5: The random function was added in Twig 1.5.
New in version 1.6: String and integer handling was added in Twig 1.6.
The random function returns a random value depending on the supplied
parameter type:
1 2 3 4 | {{ random(['apple', 'orange', 'citrus']) }} {# example output: orange #}
{{ random('ABC') }} {# example output: C #}
{{ random() }} {# example output: 15386094 (works as native PHP `mt_rand`_ function) #}
{{ random(5) }} {# example output: 3 #}
|
values: The values