Is it possible to use an operator like function?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/1692626/can-i-use-operators-as-function-callback-in-php">Can I use operators as function callback in PHP?</a>  </p>
</blockquote>



<p>Is it possible to use an operator like a function in PHP?</p>

<p>For example, I've written a little function that looks like this:</p>

<pre><code>function aggregate($values,$function,$initial=null) {
    $agg = $initial === null ? array_shift($values) : $initial;
    while($values) {
        $agg = call_user_func($function,$agg,array_shift($values));
    }
    return $agg;
}
</code></pre>

<p>I'm wondering if it would be possible to call it with something like</p>

<pre><code> agggregate(array(1,2,3),'+');
</code></pre>

<p>Which would yield <code>1+2+3=6</code>.</p>

<p>If not, I guess I could call it like this:</p>

<pre><code> agggregate(array(1,2,3),function($a,$b){return $a+$b;});
</code></pre>

<p>But it's not as compact.</p>

<hr>

<p>I just noticed this is identical to <code>array_reduce</code>; it's not necessary to point this out ;)</p>
