NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
# `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 suppliedparameter type: - a random item from a sequence; - a random character from a string; - a random integer between 0 and the integer parameter (inclusive). <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 2 3 4</pre></div></td><td class="code"><div class="highlight"><pre>{{ 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 #} </pre></div></td></tr></table> ### Arguments - `values`: The values