title: PHP get all arguments as array?
body: <p>Hey, I was working with a PHP function that takes multiple arguments and formats them.  Currently, I'm working with something like this:</p>
  
  <pre><code>function foo($a1 = null, $a2 = null, $a3 = null, $a4 = null){
      if ($a1 !== null) doSomethingWith($a1, 1);
      if ($a2 !== null) doSomethingWith($a2, 2);
      if ($a3 !== null) doSomethingWith($a3, 3);
      if ($a4 !== null) doSomethingWith($a4, 4);
  }
  </code></pre>
  
  <p>But I was wondering if I can use a solution like this:</p>
  
  <pre><code>function foo(params $args){
      for ($i = 0; $i &lt; count($args); $i++)
          doSomethingWith($args[$i], $i + 1);
  }
  </code></pre>
  
  <p>But still invoke the function the same way, similar to the params keyword in C# or the arguments array in JavaScript.</p>