Forum Moderators: coopster
for ($counter=1; $counter < $max_number_of_images; $counter++)
{
if (is_uploaded_file($imgfile["$counter"]))
{
$uploads = "uploads";
$images_dir = "$uploads/$id";
....
My file uploads are called imgfile1, imgfile2, and imgfile3. I want this for loop for go through all those. How can I tell php that in my if statement the counter variable should show up only as a 'PHP text'?
Basically php should read the if statement as:
if (is_uploaded_file($imgfile1))
if (is_uploaded_file($imgfile2))
if (is_uploaded_file($imgfile3))
Thank you, I hope that this makes sense...sorry if I am a little confusing, I am still new to PHP.
Thank you,
dombi
$imgfile1 = 'Aaron';
$i = 1;
echo ${"imgfile$i"};
will print Aaron.
Since you can access uploaded files by the $_FILES superglobal you can use this code as well:
$_FILES["imgfile$1"]
Andreas
for ($counter=1; $counter < $max_number_of_images; $counter++)
{
if (is_uploaded_file(${"imgfile".$counter}))
{
$uploads = "uploads";
$images_dir = "$uploads/$id";
So I can do something like this with a variable:
${"string".$counter."string".$counter2."string"}
Thank you once again!
dombi