[drupal-devel] array2object improvement

Moshe Weitzman weitzman at tejasa.com
Fri Sep 16 05:04:49 UTC 2005


> Forms with nested groups of elements have to be navigated as keyed
> arrays: $form['admin']['options'] for example. When a newly loaded
> object is prep'd for use using object2array($object), it flattens the
> properties to $form['options'] and so on. if you're not expecting it,

i think array2object and object2array could be simplied like so:

function array2object($arr) {
   return (object) $arr;
}

this would avoid the flattenning that you mention, as well as save some 
cycles. anyone care to test this and submit a patch if it works?



More information about the drupal-devel mailing list