Remove Line From File Script

Remove Line From File Script is used to if you select line at drop down list and then click button which line will be removed.

Demo :



Text   File Name :
   
 File Type
 
         
 
Test
     
         
  Remove Line    
       

Warning: file_get_contents(upload_files/remove-line-from-file/test.txt): failed to open stream: No such file or directory in /home/tutorialsscripts/public_html/free-php-scripts/file-and-directory-script/remove-line-from-file.php on line 153
     
         

Example :

In the above demo if you click write button after validation there will be created new test file. If you need to remove center line at text file and select drop down list and click remove button.

Code :

Following code is use to Remove Line From File Script if you need code to copy and use to your website.


<?php
$file = "Path_Name";
$data = file($file) or die("Cannot read file");
unset ($data[2]);
$data = array_values($data);
file_put_contents($file, implode($data)) or die("Cannot write to file");
?>

In the above $file variable is used to assign to path information and file() function is used to read file and store $data variables and data[2] variables is used to unset line 2 from file. In the above array_values() function is arrange the values at file and file_put_contents() function is again write the files.

Free Download Script :

If you need Remove Line From File Script click and download from following link.

Download




Content