# PHP Code Snippets Episode 2 - Use An Array To fill a Option Box

In this post I am going to show you how to take the values from an array and use them, in a form option box.

## Makingasimplearray

First of all we are going to make a simple array..

For this example i will just make a basic array, however you could use a _mysqletchandom	ext	o/ to read data from a database to make your array then continue with step 2.

I will show you the basics of this in my next tutorial.

## Example

```javascript
<?php
$options = ["option_1","option_2","option_3","option_4","option_5","option_6"];
?>

<form>
    <select name="example">
        <?php
            foreach($options as $choice) {
                echo '<option value="'.$choice.'">'.$choice.'</option>';
            }
        ?>
    </select>
</form>
```

As you can see this will give you all the options from the array into your option choices.

I hope this little snippet will help.

## Nexttime

To view the next tutorial where i use a database to get information please [click here](https://southcoastweb.dsm.pw/uncategorised/php-code-snippets-part-3-database-information-into-option-dropdown-box/).
