Skip to content

Commit

Permalink
add method Reader\AbstractReader::firstColumns
Browse files Browse the repository at this point in the history
  • Loading branch information
kentreez committed Jul 31, 2022
1 parent 39b6e8b commit 55caa80
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ Because of using Generator for iterate over input file's rows. **DO NOT BREAK**
print_r($rows);
}

// if we interest only first column of each row then
foreach ($easy->firstColumns() as $str) {
echo $str . PHP_EOL;
}
?>
10 changes: 10 additions & 0 deletions src/Reader/AbstractReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,14 @@ public function count (): int

return $this->count_rows;
}

/**
* @throws ReaderException
*/
public function firstColumns (): Generator
{
foreach ($this->rows() as $row) {
yield $row[0];
}
}
}

0 comments on commit 55caa80

Please sign in to comment.