public static function offsetLine($lines, $offset) { $iMax = count($lines); for ($i = 0; $i < $iMax; $i++) { if ($lines[$i] > $offset) { return $i + 1; } } return $iMax; }