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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux