Skip to content

Instantly share code, notes, and snippets.

@wchristian
Created September 27, 2010 14:35
Show Gist options
  • Save wchristian/599131 to your computer and use it in GitHub Desktop.
Save wchristian/599131 to your computer and use it in GitHub Desktop.
<?php
$array[0] = array(1600,1601,1602,1603);
$array[1] = array(1601,1602,1603,1604);
$array[2] = array(1602,1603,1604,1605);
$num_filter = make_filter( "/^160[23]$/" );
$hits = array_map( $num_filter, $array );
exit;
function make_filter ( $pattern ) {
$code = 'return preg_grep( "'.$pattern.'", $array );';
$filter_func = create_function( '$array', $code );
return $filter_func;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment