Generator::key

(PHP 5 >= 5.5.0, PHP 7)

Generator::keyGet the yielded key

Opis

public Generator::key ( void ) : mixed

Gets the key of the yielded value.

Parametry

Ta funkcja nie posiada parametrów.

Zwracane wartości

Returns the yielded key.

Przykłady

Przykład #1 Generator::key() example

<?php

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

$gen Gen();

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

Powyższy przykład wyświetli:

key => value

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top