Files
cssd-back/app/Helpers/helpers.php
T

18 lines
545 B
PHP

<?php
if (!function_exists('pluckValues')) {
/**
* Extracts the values of a given key from an array of associative arrays.
*
* @param array $array The input array of associative arrays.
* @param string $key The key whose values need to be extracted.
* @return array An array containing the values of the specified key.
*/
function pluckValues(array $array, string $key): array
{
return array_map(function ($item) use ($key) {
return $item[$key] ?? null;
}, $array);
}
}