function _webform_shuffle_options in Webform 7.4
Same name and namespace in other branches
- 6.3 components/select.inc \_webform_shuffle_options()
- 7.3 components/select.inc \_webform_shuffle_options()
Utility function to shuffle an array while preserving key-value pairs.
2 calls to _webform_shuffle_options()
- webform_expand_grid in components/
grid.inc - A Form API #process function for Webform grid fields.
- _webform_render_select in components/
select.inc - Implements _webform_render_component().
File
- components/
select.inc, line 1095 - Webform module multiple select component.
Code
function _webform_shuffle_options(&$array) {
// First shuffle the array keys, then use them as the basis for ordering
// the options.
$aux = array();
$keys = array_keys($array);
shuffle($keys);
foreach ($keys as $key) {
$aux[$key] = $array[$key];
}
$array = $aux;
}