title: PHP call_user_function using references
body: <p>Here's main application:</p>
  
  <pre><code>$test=array();
  invoke_hooks("hook",$test);
  </code></pre>
  
  <p>Two functions of hook:</p>
  
  <pre><code>function first_hook(&amp;$a = array()) {
      $a[40] = "1";
  }
  
  function second_hook(&amp;$a = array()) {
      $a[300] = "2";
  }
  
  function invoke_hooks($hook_name) {
      $args = func_get_args();
      array_shift($args);
      $functions = get_defined_functions();
      foreach ($functions as $f) {
          if (substr($f, -strlen($hook_name)) === $hook_name) {
              call_user_func_array($f, &amp;$args);
          }
      }
  }
  </code></pre>
  
  <p>The idea is to get :</p>
  
  <pre><code>$test[40]=="1";
  $test[300]=="2";
  </code></pre>
  
  <p>How can I make it?</p>