Skip to content

PHP use of array in form ?

Here is a simple example how to use array in html form element to store multiple value under single name.
<title>Use of array in form</title>
<h1>Use of array in form</h1>

your favourite artists:
echo implode($_REQUEST['artists']," , ");

<form method="post">
Select your favourite artists: <br />
<select name="artists[]" multiple="true">
<option value="Amitabh Bachan">Amitabh Bachan</option>
<option value="Shahrukh Khan">Shahrukh Khan</option>
<option value="Aamir Khan">Aamir Khan</option>
<option value="Salman Khan">Salman Khan</option>
<option value="Ajay Devgan">Ajay Devgan</option>
<input type="submit" name="submit" value="Submit" />