Returns an Iterable view of the current Vector

public function items(): Iterable<Tv>;

The Iterable returned is one that produces the values from the current Vector.



This example shows that items() returns an Iterable view of the Vector. The Iterable will produce the values of the Vector at the time it's iterated.

function basic_usage_main(): void {
  $v = Vector {'red', 'green', 'blue', 'yellow'};

  // Get an Iterable view of the Vector
  $iterable = $v->items();

  // Add another color to the original Vector $v

  // Print each color using $iterable
  foreach ($iterable as $color) {
    echo $color."\n";

// This wouldn't work because the Iterable interface is read-only:
// $iterable->add('orange');