I have this snippet in a HTML file. But I want that a file name gets changed if its opened from 1unread.txt to 1read.txt so it will get in the list of read.
<h2>Unread</h2>
<?php
foreach (glob("*1unread.txt") as $filename) {
echo "<a href='$filename'>Download {$filename}</a><br>" . "
" ;
}
?>
<h2>Read</h2>
<?php
foreach (glob("*1read.txt") as $filename) {
echo "<a href='$filename'>Download {$filename}</a><br>" . "
" ;
}
?>
If have read on php.net that I can change a file name with this:
bool rename ( string $oldname , string $newname [, resource $context ] )
but how do I make this happen when the download linked is used? And what does the variable $context
do? I am kinda new to PHP so don't expect much from me to understand :P
Thanks anyway