Formatting array

Links for php scripts

Moderators: macek, egami, gesf

showerhead
New php-forum User
New php-forum User
Posts: 1
Joined: Fri Sep 06, 2013 2:44 am

Formatting array

Postby showerhead » Fri Sep 06, 2013 3:05 am

Hi how can I take inputs from a form and create a new multi dimensional array out of it. ** note, number of form inputs could fluctuate. I would like to take the form inputs and turn it into the following:

Any help appreciated. thank you

$data = array(
array('10:30','start'),
array('11:23','end'),
array('11:22','start'),
array('12:30','end'),
array('14:25','start'),
array('15:30','end'),
);



<form action="test3.php" method="post">

1 Start time<input type="text" name="startTime[]" /> <input type="text" name="endTime[]" /><br/ >
2 Start time<input type="text" name="startTime[]" /> <input type="text" name="endTime[]" /><br/ >
3 Start time<input type="text" name="startTime[]" /> <input type="text" name="endTime[]" /><br/ >
4 Start time<input type="text" name="startTime[]" /> <input type="text" name="endTime[]" /><br/ >
5 Start time<input type="text" name="startTime[]" /> <input type="text" name="endTime[]" /><br/ >

<input type="hidden" name="submitted" value="true" />

<input type="submit" name="Submit" value="Go" />

</form>

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Formatting array

Postby johnj » Sun Sep 22, 2013 12:37 am

What is wrong with what you are doing right now?


Return to “PHP Scripts”

Who is online

Users browsing this forum: No registered users and 1 guest

cron