Jump to content

Recommended Posts

i have a form which will submit an x amount of file names. x meaning the user can select how many files he/she wants to zip. I can get the possible number of files the user can select. Now heres my problem

 

When the form information is sent each check box has the name zip1 zip2 ect. The number after each zip will differ depening on how many files are in the directory the user is looking at.

 

so i have the number after each zip but i need away to print all the filenames sent from the form into an array. I thought of something like

 

for($i = 0; $i < $_POST['number']; $i++)
{

echo $_POST['zip'.$i];

}

 

$_POST['number'] is the value of possible files the user can select to zip.

 

but nothing happens any ideas?

Link to comment
https://forums.phpfreaks.com/topic/122720-solved-array-help/
Share on other sites

You are better defining the checkbox name as an array so no loop is required:

 

<input type="checkbox" name="zipnum[]" value="1" />
<input type="checkbox" name="zipnum[]" value="2" />
<input type="checkbox" name="zipnum[]" value="3" />

and so on

 

Then you can just view the values in the post array

print_r($_POST['zipnum']);

Link to comment
https://forums.phpfreaks.com/topic/122720-solved-array-help/#findComment-633756
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.