+

PHP SplFileObject setMaxLineLen () function

Syntax:
void SplFileObject::setMaxLineLen ($len)
Parameters: This function takes one parameter, $len, which is used to specify the maximum string length.Return Values:This function returns the maximum string length. The default is 0.The following programs illustrate the SplFileObject::setMaxLineLen() function in PHP:Program 1:  
// Create SplFile object $gfg = new SplFileObject ( " gfg.txt " );  
// Print length var_dump ( $gfg -> getMaxLineLen());  
// Set length $gfg -> setMaxLineLen (20); var_dump ( $gfg -> getMaxLineLen());  
?>
Output:
int (0) int (20)
Program 2:  
// Create array $GFG = array ( "dummy.txt" , "gfg.txt" , "frame.txt" );  
// Create a Spl object foreach ( $GFG as & amp; $arr ) { // Create a SplFile object $gfg = new SplFileObject ( $arr ) ; // Print length up to var_dump ( $gfg -> getMaxLineLen()); // Set length $gfg -> setMaxLineLen (50); echo "After =" ; // Print length after var_dump ( $gfg -> getMaxLineLen()); echo " < / br > " ; } ?>
Exit:
int (0 ) After = int (50) int (0) After = int (50) int (0) After = int (50)
Link:http://php.net/manual/en/splfileobject.setmaxlinelen.php
Get Solution for free from DataCamp guru