Populating A Drop-Down List In PHP v.2

 

This script will show you how to populate a drop-down list in php v.2.

 

Example

 

 

 

Script Source

<?php
$arr = array("selection one", "selection two", "selection three", "selection four");

echo "<select name=\"drop_box\"><option value=\"choose\">Choose Selection</option>";

for($i=0; $i < count($arr); $i++)
echo "<option value=\". $arr[$i] .\">$arr[$i]</option>";

echo "</select>";
?>

 

Please let me know if this script was helpful to you.

[rating]