Created
July 21, 2010 15:14
-
-
Save RobertAudi/484624 to your computer and use it in GitHub Desktop.
Return array keys that match the pattern.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function preg_grep_keys( $pattern, $input, $flags = 0 ) | |
{ | |
$keys = preg_grep( $pattern, array_keys( $input ), $flags ); | |
$vals = array(); | |
foreach ( $keys as $key ) | |
{ | |
$vals[$key] = $input[$key]; | |
} | |
return $vals; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Retrieved from this comment on the php preg_grep manual page.