Skip to content

Instantly share code, notes, and snippets.

@wouerner
Created June 16, 2013 12:12
Show Gist options
  • Save wouerner/5791860 to your computer and use it in GitHub Desktop.
Save wouerner/5791860 to your computer and use it in GitHub Desktop.
<?php
function reducer($total, $elt)
{
return $elt + $total;
}
$arr = array(1, 2, 3, 4, 5);
echo array_reduce($arr, 'reducer', 1);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment