Skip to content

Instantly share code, notes, and snippets.

@speedmax
Created March 15, 2009 23:10
Show Gist options
  • Save speedmax/79577 to your computer and use it in GitHub Desktop.
Save speedmax/79577 to your computer and use it in GitHub Desktop.
function evaluate_block($block, $arguments = array()) {
# implict return
$lines = explode(';', $block);
$last =& $lines[count($lines)-2];
if (strpos($last, 'return') === false) {
$last = 'return '.$last;
}
$block = join(';', $lines);
if (isset($arguments['this'])) {
$arguments['self'] = $arguments['this'];
unset($arguments['this']);
}
unset($arguments['block']);
extract($arguments);
return eval($block);
}
echo "***INJECT***\n";
print_r($e->inject(array(), '#| $object, $key, $value |
$object["injected_$key"] = $value;
$object;
'));
$e->map('$object->id;');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment