PHP.nl

Generator::key

Generator::key

Get the yielded key

mixed **Generator::key**

Gets the key of the yielded value.

Returns the yielded key.

Voorbeeld: example

<?php

function Gen()
{
    yield 'key' => 'value';
}

$gen = Gen();

echo "{$gen->key()} => {$gen->current()}";
key => value

Documentatie