Skip to content

Instantly share code, notes, and snippets.

@aklump
Last active December 28, 2015 03:09
Show Gist options
  • Save aklump/7432897 to your computer and use it in GitHub Desktop.
Save aklump/7432897 to your computer and use it in GitHub Desktop.
PHP: Convert a renderable Drupal array's properties to children.
/**
* Convert all element properties to children
*
* @param array $array An array with one or more keys that begine with '#' .
*
* @return array Any key that began with '#' will have the # stripped.
*/
function element_properties_to_children($array) {
$keys = array_map(create_function('$item', 'return substr($item, 1);'), array_keys($array));
return array_combine($keys, $array);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment