Skip to content

Instantly share code, notes, and snippets.

@jhyland87
Created September 27, 2016 13:14
Show Gist options
  • Select an option

  • Save jhyland87/c8202741f738a0e873ce840cf3775490 to your computer and use it in GitHub Desktop.

Select an option

Save jhyland87/c8202741f738a0e873ce840cf3775490 to your computer and use it in GitHub Desktop.
<?php
$to_iterate = get_defined_constants();
function do_filter($k) {
if(count($argv)){
array_pop($argv);
$pattern = '/^('.implode($argv,'|') .')_/i';
return preg_match( $pattern, $k ) > 0;
}
else {
return TRUE;
}
}
var_dump(array_filter($to_iterate, do_filter, ARRAY_FILTER_USE_KEY));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment