note 111673 added to function.preg-grep
| From: | DanielKlein | Date: | Thu, 14 Mar 2013 22:54:11 +0000 |
| Subject: | note 111673 added to function.preg-grep | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-194079@lists.php.net to get a copy of this message | ||
A shorter way to run a match on the array's keys rather than the values:
<?php
function preg_grep_keys($pattern, $input, $flags = 0) {
return array_intersect_key($input, array_flip(preg_grep($pattern, array_keys($input), $flags)));
}
?>
----
Server IP: 69.147.83.199
Probable Submitter: 202.59.29.222
----
Manual Page -- http://php.net/manual/en/function.preg-grep.php
Edit -- https://master.php.net/note/edit/111673
Del: integrated -- https://master.php.net/note/delete/111673/integrated
Del: useless -- https://master.php.net/note/delete/111673/useless
Del: bad code -- https://master.php.net/note/delete/111673/bad+code
Del: spam -- https://master.php.net/note/delete/111673/spam
Del: non-english -- https://master.php.net/note/delete/111673/non-english
Del: in docs -- https://master.php.net/note/delete/111673/in+docs
Del: other reasons-- https://master.php.net/note/delete/111673
Reject -- https://master.php.net/note/reject/111673
Search -- https://master.php.net/manage/user-notes.php