PHP | SplFileObject seek() Function Last Updated : 24 Dec, 2018 Comments Improve Suggest changes Like Article Like Report The SplFileObject::seek() function is an inbuilt function of Standard PHP Library (SPL) in PHP which is used to seek to specify the line. Syntax: void SplFileObject::seek( $line_num) Parameters: This functions accept only one parameter $line_num which specifies the line number of the file. Return values: This function does not return any value. Below Programs illustrate the SplFileObject::seek () function in PHP: Program-1: php <?php // PHP program to illustrate // SplFileObject Seek function $file = new SplFileObject(__FILE__); $file->seek(3); echo $file->current(); ?> Output: // SplFileObject Seek function Program-2: php <?php // PHP program to use array to check // multiple files $GFG = array( "/home/rajvir/Desktop/GeeksforGeeks/dummy.php", "gfg.txt", "mime.php" ); foreach ($GFG as &$file_name) { $file = new SplFileObject($file_name); $file->seek(3); echo $file->current(); } ?> Output: GeeksforGeeks gfg contribute Reference: http://php.net/manual/en/splfileobject.seek.php Comment More infoAdvertise with us Next Article PHP | SplFileObject seek() Function R R_Raj Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-SplFileInfo Similar Reads PHP | SplFileObject eof() Function The SplFileObject::eof() function is an inbuilt function of Standard PHP Library (SPL) in PHP which is used reached end of file. Syntax: string SplFileObject::eof( void ) Parameters: This function does not accept any parameter. Return values: Returns TRUE on Success. Below Programs illustrate the Sp 1 min read PHP SplFileObject key() Function The SplFileObject::key() is an inbuilt function of the Standard PHP Library (SPL) in PHP that is used to get the key (line number) of the current line pointed to by the SplFileObject. Syntaxpublic SplFileObject::key(): intParameter This function does not have any parameters. Return Value The SplFile 2 min read PHP | SplFileObject setMaxLineLen() Function The SplFileObject::setMaxLineLen() function is an inbuilt function of Standard PHP Library (SPL) in PHP which is used to set the maximum length of line length. Syntax: void SplFileObject::setMaxLineLen( $len ) Parameters: This function accepts single parameter $len which is used to specify the maxim 1 min read PHP SplFileObject next() Function The SplFileObject::next() is an inbuilt function in PHP that is used to iterate the file using the SplFileObject. The pointer will point next line. The SplFileObject implements Iterator and Traversal. That means you can use it in foreach loops and use many of the iterator functions with it. Syntaxpu 2 min read PHP | SplFileObject fgets() Function The SplFileObject::fgets() function is an inbuilt function of the Standard PHP Library (SPL) in PHP which is used to get a line from the file. Syntax: string SplFileObject::fgets( void ) Parameters: This function does not accept any parameter. Return values: This function returns a string contain 1 min read Like