mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-22 11:36:23 +00:00
33 lines
492 B
Markdown
33 lines
492 B
Markdown
---
|
|
date: 2020-11-12
|
|
id: f5983e81-f975-4913-b6c5-5211493841b7
|
|
title: iterate() method
|
|
---
|
|
|
|
# Syntax
|
|
|
|
``` php
|
|
$iterable = function () {
|
|
yield 1;
|
|
yield 2;
|
|
// ...
|
|
};
|
|
```
|
|
|
|
``` php
|
|
use Symfony\Component\Console\Helper\ProgressBar;
|
|
|
|
$progressBar = new ProgressBar($output);
|
|
|
|
foreach ($progressBar->iterate($iterable) as $value) {
|
|
// ... do some work
|
|
}
|
|
```
|
|
|
|
## Non countable variable
|
|
|
|
``` php
|
|
foreach ($progressBar->iterate($iterable, 100) as $value) {
|
|
// ... do some work
|
|
}
|
|
```
|