Quantcast
Channel: How to remove a line from text file using php without leaving an empty line - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by Melsi for How to remove a line from text file using php without leaving an empty line

$
0
0

You can improve this by setting conditions to predict errors.

<?PHP$file = "a.txt";$line = 3-1;$array = file($file);unset($array[$line]);$fp = fopen($file, 'w+');foreach($array as $line)     fwrite($fp,$line); fclose($fp);?>

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>