title: How do I create a dictionary of functions in PHP?
body: <p>I want to have a dictionary of functions. With this dictionary, I could have a handler that accepts a function name and an array of arguments, and executes that function, returning the value it returns if it returns anything. The handler would throw an error if the name does not correspond to an existing function.</p>
  
  <p>This would be very simple to implement Javascript:</p>
  
  <pre><code>var actions = {
    doSomething: function(){ /* ... */ },
    doAnotherThing: function() { /* ... */ }
  };
  
  function runAction (name, args) {
    if(typeof actions[name] !== "function") throw "Unrecognized function.";
    return actions[name].apply(null, args);
  }
  </code></pre>
  
  <p>But since functions aren't really first class objects in PHP, I can't figure out how to do this easily. Is there a reasonably simple way to do this in PHP?</p>