Skip to content

Instantly share code, notes, and snippets.

@carlbennett
Created December 9, 2015 22:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlbennett/86dc1663ba97dfdc5952 to your computer and use it in GitHub Desktop.
Save carlbennett/86dc1663ba97dfdc5952 to your computer and use it in GitHub Desktop.
#!/usr/bin/php
<?php
function closure_test(&$foobar) {
// Repeat for some arbitrary number of executions
$x = mt_rand(3, 10);
while ($x > 0) {
$foobar[] = $x;
--$x;
}
$closure = function(&$foobar) {
$foobar[mt_rand(0, count($foobar) - 1)] = "this row got changed!";
};
$closure($foobar);
}
$foobar = [];
closure_test($foobar);
print_r($foobar);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment