Generates replacement values for a list of tokens.
$type: The type of token being replaced. 'node', 'user', and 'date' are common.
$tokens: An array of tokens to be replaced, keyed by the literal text of the token as it appeared in the source text.
$data: (optional) An array of keyed objects. For simple replacement scenarios 'node', 'user', and others are common keys, with an accompanying node or user object being the value. Some token types, like 'site', do not require any explicit information from $data and can be replaced even if it is empty.
$options: (optional) A keyed array of settings and flags to control the token replacement process. Supported options are:
An associative array of replacement values, keyed by the original 'raw' tokens that were found in the source text. For example: $results['[node:title]'] = 'My new node';
function token_generate($type, array $tokens, array $data = array(), array $options = array()) {
$options += array(
'sanitize' => TRUE,
);
$replacements = module_invoke_all('tokens', $type, $tokens, $data, $options);
// Allow other modules to alter the replacements.
$context = array(
'type' => $type,
'tokens' => $tokens,
'data' => $data,
'options' => $options,
);
drupal_alter('tokens', $replacements, $context);
return $replacements;
}