When you're theming, you might do something like this in a preprocess function:

$variables['name'] = 'Bob';

That 'name' would eventually become a real variable that could be accessed in the template as $name. How does Drupal convert an array of key/value pairs into *actual variables* that can be accessed in the templates?

Comments

kpander’s picture

The concept you're referring to is 'Variable variables'. You can read about it here: http://php.net/manual/en/language.variables.variable.php

More specifically, you can use the 'extract()' function: http://ca3.php.net/extract