qlithe
Supreme Member
- Feb 14, 2012
- 1,252
- 288
This is driving me crazy. It's obviously not the entire code but it illustrates my problem.
For some reason, it refuses to output the files correctly when I use $filename as the 'to' parameter in imagepng. When the code looks like above, only one file is created with the last filename.
But changing the line to ($filename to $i):
Works just perfect. All files are created named 0.png, 1.png etc
PHP:
<?php
$filenames = file('filenames.txt');
for ($i = 0; $i <= count($filenames)-1; $i++)
{
$filename = $filenames[$i];
imagepng($im, $filename . '.png');
imagedestroy($im);
}
?>
For some reason, it refuses to output the files correctly when I use $filename as the 'to' parameter in imagepng. When the code looks like above, only one file is created with the last filename.
But changing the line to ($filename to $i):
PHP:
imagepng($im, $i . '.png');
Works just perfect. All files are created named 0.png, 1.png etc