Fri, 17 May 2024


How do I create arrays in a HTML <form>?

By: Anton, NetArt Media
Fri, 23 October 2020

To get your <form> result sent as an array to your PHP script you name the <input>, <select> or <textarea> elements like this:

<input name="catlist[]">
<input name="catlist[]">
<input name="catlist[]">
<input name="catlist[]">


Treat the received information in your PHP script like this:

$num_cat = count ($catlist);

for ($i = 0; $i < $num_cat; $i++)
{
... $catlist[$i] ...

}


Category: PHP Examples
Share this post:



See All Scripts






Subscribe for our newsletter

Receive the latest blog posts direct in your mailbox