diff options
| author | Zhineng Li <[email protected]> | 2026-02-14 10:08:30 +0800 |
|---|---|---|
| committer | Zhineng Li <[email protected]> | 2026-02-14 10:08:30 +0800 |
| commit | eccd5cd5a067f5659982685afdeea209b1888efb (patch) | |
| tree | 1626c903b854317be1708ce3ccd3b4f4e6e0fc97 /build/Arr.php | |
| download | acs-metadata-1.0.0+20260212.tar.gz acs-metadata-1.0.0+20260212.zip | |
first commitHEADv1.0.0+20260212main
Diffstat (limited to 'build/Arr.php')
| -rw-r--r-- | build/Arr.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/build/Arr.php b/build/Arr.php new file mode 100644 index 0000000..e9f357d --- /dev/null +++ b/build/Arr.php @@ -0,0 +1,26 @@ +<?php + +declare(strict_types=1); + +final class Arr +{ + /** + * Extract the specified keys from the given array. + * + * @param array<array-key, mixed> $array + * @param array<int, array-key> $keys + * @return array<array-key, mixed> + */ + public static function only(array $array, array $keys): array + { + $result = []; + + foreach ($keys as $key) { + if (array_key_exists($key, $array)) { + $result[$key] = $array[$key]; + } + } + + return $result; + } +} |
