Convert an associative array to an anonymous object.
6 calls to array2object()
- comment_preview in modules/
comment.module - node_access in modules/
node.module - Determine whether the current user may perform the given operation on the specified node.
- node_preview in modules/
node.module - Generate a node preview, including a form for further edits.
- node_validate in modules/
node.module - Perform validation checks on the given node.
- node_view in modules/
node.module - Generate a display of the given node.
File
- includes/
common.inc, line 423 - Common functions that many Drupal modules will need to reference.
Code
function array2object($array) {
if (is_array($array)) {
$object = new StdClass();
foreach ($array as $key => $value) {
$object->{$key} = $value;
}
}
else {
$object = $array;
}
return $object;
}