Created
February 10, 2015 04:51
-
-
Save slav123/85ec7d5c248cf5628e2e to your computer and use it in GitHub Desktop.
return only given key from bigger array
This file contains hidden or 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 | |
/** | |
* capture only id from bigger array | |
* | |
* @param array $array input | |
* @param array $pkey primary key | |
* | |
* @return array | |
*/ | |
function array_id($array, $pkey) | |
{ | |
$checker = function($value) use ($pkey) { | |
if (array_key_exists($pkey, $value)) return $value[$pkey]; | |
}; | |
return array_map($checker, $array); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment