Hi there, I have this script below, which should rename a file with a word randomly picked from a txt file. Please could somebody tell me why it is not working? Thanks <?php $filename="words.txt"; $words=file($filename); shuffle($words); $word = $words[0]; $old = 'tmp/today.php'; $new = 'tmp/'.$word.'.php'; rename($old, $new) or die("Unable to rename $old to $new."); ?> PHP: txt file adult aeroplane air airforce airport album alphabet apple arm PHP: Thanks
I've tried that. I've also noticed that the script works fine just like this: <?php $old = 'tmp/today.php'; $new = 'tmp/tomorrow'.php'; rename($old, $new) or die("Unable to rename $old to $new."); ?> PHP: and the part which gets the words also works fine on its own: <?php $filename="words.txt"; $words=file($filename); shuffle($words); $word = $words[0]; echo $word; ?> PHP: It's just when you join them both together that it doesn't work :S