$data = [
['test' => 'xxxx'],
['test' => 'aaaa'],
['test' => 'z2Gtui345mxQp'],
['test222' => 'z2Gtui345mxQp']
];
$key = 'test';
$groupedData = array_map(fn ($item) => sprintf('API_%s', ($item[$key] ?? '')), $data);
var_dump($groupedData);
$groupedData2 = array_map(function ($item) use ($key) {
return sprintf('API_%s', $item[$key] ?? '');
}, $data);
var_dump($groupedData2);
array(4) {
[0]=>
string(8) "API_xxxx"
[1]=>
string(8) "API_aaaa"
[2]=>
string(17) "API_z2Gtui345mxQp"
[3]=>
string(4) "API_"
}