I try to find out how we can get keys from an \Generator()
that yield values of an array.
What i actually do :
function t(): \Generator {
yield from [
'hello' => 0,
'yellow' => 1,
'coco' => 2,
];
}
$keys = \array_keys(\iterator_to_array(t()));
var_dump($keys);
array(3) {
// [0]=>
// string(5) "hello"
// [1]=>
// string(6) "yellow"
// [2]=>
// string(6) "grolow"
// }
What is the efficient way to do this ?