Can't save multiple files if I'm using values pulled from another file...

From: Date: Thu, 03 Mar 2005 11:53:16 +0000
Subject: Can't save multiple files if I'm using values pulled from another file...
Groups: php.general 
Request: Send a blank email to php-general+get-209896@lists.php.net to get a copy of this message
I'm writing a script that transfers files from a list file and saves them locally. M If I use values from the list for the filenames of the saved files, it appears that none of the files are saved 'cept for the last one. If I put the values in an array directly in the script file, all is well. I have confirmed that the values are different and I've tried other methods to load the file, such as fgets. Here is a simplified version of my script that has the same problem: <?php $linklist = file('links.txt'); foreach ($linklist as $link) { echo "saving to $link<br>"; // confirm link name $file = fopen ($link, 'w'); // write dummy text to file fwrite($file, 'blah'); fclose($file); } ?> And in links.txt I have: link one link two link three If I run the script, the only file that will have been created is "link three" or whatever is on the bottom. If however, I replace the first line with: $linklist = array("link one", "link two", "link three"); Then the script works as expected. What am I missing? I've wasted three hours trying to figure this out and I don't know what I could be screwing up. :( Foofy -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

« previous php.general (#209896) next »