src/Ubiquity/utils/base/UFileSystem.php
public static function getLines($filename, $reverse = false, $maxLines = null, $lineCallback = null) {
		if (file_exists ( $filename )) {
			if ($reverse && isset ( $maxLines )) {
				$result = [ ];
				$fl = fopen ( $filename, "r" );
				for($x_pos = 0, $ln = 0, $lines = [ ]; fseek ( $fl, $x_pos, SEEK_END ) !== - 1; $x_pos --) {
					$char = fgetc ( $fl );
					if ($char === "\n") {
						if (is_callable ( $lineCallback )) {
							$lineCallback ( $result, $lines [$ln] );
						} else {
							$result [] = $lines [$ln];
						}
						if (isset ( $maxLines ) && sizeof ( $result ) >= $maxLines) {
							fclose ( $fl );
							return $result;
						}
						$ln ++;
						continue;
					}
					$lines [$ln] = $char . ((array_key_exists ( $ln, $lines )) ? $lines [$ln] : '');
				}
				fclose ( $fl );
				return $result;
			} else {
				return self::getLinesByLine ( $filename, $reverse, $maxLines, $lineCallback );
			}
		}
		return [ ];
	}
public static function getLines($filename, $reverse = false, $maxLines = null, $lineCallback = null) {
		if (file_exists ( $filename )) {
			if ($reverse && isset ( $maxLines )) {
				$result = [ ];
				$fl = fopen ( $filename, "r" );
				for($x_pos = 0, $ln = 0, $lines = [ ]; fseek ( $fl, $x_pos, SEEK_END ) !== - 1; $x_pos --) {
					$char = fgetc ( $fl );
					if ($char === "\n") {
						if (is_callable ( $lineCallback )) {
							$lineCallback ( $result, $lines [$ln] );
						} else {
							$result [] = $lines [$ln];
						}
						if (isset ( $maxLines ) && sizeof ( $result ) >= $maxLines) {
							fclose ( $fl );
							return $result;
						}
						$ln ++;
						continue;
					}
					$lines [$ln] = $char . ((array_key_exists ( $ln, $lines )) ? $lines [$ln] : '');
				}
				fclose ( $fl );
				return $result;
			} else {
				return self::getLinesByLine ( $filename, $reverse, $maxLines, $lineCallback );
			}
		}
		return [ ];
	}
public static function getLines ( $ filename , $ reverse = false , $ maxLines = null , $ lineCallback = null ) { if ( file_exists ( $ filename ) ) { if ( $ reverse && isset ( $ maxLines ) ) { $ result = [ ] ; $ fl = fopen ( $ filename , "r" ) ; for ( $ x_pos = 0 , $ ln = 0 , $ lines = [ ] ; fseek ( $ fl , $ x_pos , SEEK_END ) !== - 1 ; $ x_pos -- ) { $ char = fgetc ( $ fl ) ; if ( $ char === "\n" ) { if ( is_callable ( $ lineCallback ) ) { $ lineCallback ( $ result , $ lines [ $ ln ] ) ; } else { $ result [ ] = $ lines [ $ ln ] ; } if ( isset ( $ maxLines ) && sizeof ( $ result ) >= $ maxLines ) { fclose ( $ fl ) ; return $ result ; } $ ln ++ ; continue ; } $ lines [ $ ln ] = $ char . ( ( array_key_exists ( $ ln , $ lines ) ) ? $ lines [ $ ln ] : '' ) ; } fclose ( $ fl ) ; return $ result ; } else { return self :: getLinesByLine ( $ filename , $ reverse , $ maxLines , $ lineCallback ) ; } } return [ ] ; }
Returns the lines of a file in an array

@param string $filename
@param boolean $reverse
@param null|int $maxLines
@param callback $lineCallback
@return array
Returns the lines of a file in an array