Jump to content

[SOLVED] array help


adam291086

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.