Skip to content

Instantly share code, notes, and snippets.

@RadoRado
Created March 21, 2013 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RadoRado/338b3207ba80a031de71 to your computer and use it in GitHub Desktop.
Save RadoRado/338b3207ba80a031de71 to your computer and use it in GitHub Desktop.
array_map example
<?php
function multiply($x = array(), $y = 2)
{
$multiplier = function($value) use ($y) {
return $value * $y;
};
$x = array_map($multiplier, $x);
return $x;
}
$x = array(1,2,3,4);
$x = multiply($x, 3);
var_dump($x);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment