Friday, 13 April 2012

Dropdown Box from an Array

<?php
// Array contents
$array1 = array('Sydney','Melbourne','Brisbane','Tasmania','Adelaide','Perth','Darwin','ACT');
 
// Values from array 1
echo'<select name="cities">';
// For each value of the array assign variable name "city"
foreach($array1 as $city){
    echo'<option value="'.$city.'">'.$city.'</option>';
}
echo'</select>';
?>

No comments:

Post a Comment