Commit 73c63993 authored by Penny Leach's avatar Penny Leach
Browse files

added mixed_array_to_field_array function to convert (eg) array of user

objects to array of user ids
parent 015bef3e
......@@ -607,6 +607,20 @@ function hsc ($text) {
return htmlspecialchars($text, ENT_COMPAT, 'UTF-8');
* function to convert an array of objects to
* an array containing one field per place
* @param array $array input array
* @param mixed $field field to look for in each object
function mixed_array_to_field_array($array, $field) {
$repl_fun = create_function('$n, $field', '$n = (object)$n; return $n->{$field};');
$fields = array_pad(array(), count($array), $field);
return array_map($repl_fun, $array, $fields);
* Used by XMLDB
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment