Skip to content

Instantly share code, notes, and snippets.

View nhtahoe's full-sized avatar

Nicholaus Harris nhtahoe

View GitHub Profile
@nhtahoe
nhtahoe / file-line-generator-helper-function.php
Last active September 10, 2019 16:31
Returns a Generator representation of file lines that we can then iterator over with foreach
if (!function_exists('getFileLines')) {
/**
* Returns a Generator representation of file lines that we can then iterator over with foreach
*
* eg:
* $fileData = getFileLines('path.txt');
* foreach ($fileData() as $line) {
* // $line contains current line
* }
*