Skip to content

Instantly share code, notes, and snippets.

@frosas
Created March 15, 2012 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frosas/2043106 to your computer and use it in GitHub Desktop.
Save frosas/2043106 to your computer and use it in GitHub Desktop.
Example of defining and calling PHP closures anywhere
<?php
// ...
$formBuilder->add('user', 'choice', array(
'choices' => call_user_func(function() use ($users) {
$choices = array();
foreach ($users as $user) $choices[$user->id] = $user->name;
return $choices;
})
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment