$names = ["Alex" => "23", "Oleg" => "20", "Roman" => "22", "Sasha" => "19", "Dima" => "32", "Artur" => "25"];
function getElement(array $array, int $counter): array
{
$i = 1;
foreach ($array as $key => $value) {
if ($i === $counter) {
return [$key => $value];
}
$i++;
}
}
$a = ["Alex" => "23", "Oleg" => "20", "Roman" => "22", "Sasha" => "19", "Dima" => "32", "Artur" => "25"];
var_dump(getElement($a, 4));