[drupal-devel] array2object improvement

Gabor Hojtsy gabor at hojtsy.hu
Fri Sep 16 16:07:31 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?

There is no need to have this simple function if a casting works in all
cases in Drupal.

Goba



More information about the drupal-devel mailing list