Hack Forums
PHP help, Display contents of txt file then delete afterwards - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Computing (https://hackforums.net/forumdisplay.php?fid=88)
+---- Forum: Computing Lounge (https://hackforums.net/forumdisplay.php?fid=8)
+---- Thread: PHP help, Display contents of txt file then delete afterwards (/showthread.php?tid=5700249)



PHP help, Display contents of txt file then delete afterwards - Irla - Aug 21, 2017

EDIT: I have found a solution !


I've tried so many different ways, the closest i got was it would read the first character then delete the whole text file,

I want the full text file to be displayed then to delete it.

This is what i've got so far
PHP Code

<?php
    $myFile 
= "somefile.txt";
    
$fh = fopen($myFile, 'r');
    
$theData = fread($fh, 1);
    
fclose($fh);
    echo 
$theData;
    
?>     


<?php 
array_map
('unlink', glob("somefile.txt")); 
?>

^^ yes i know i'm shit with php