I'm trying to create a drop down box that is populated by an array. When I view my code the browser just displays pieces of the php code.
Here is what the browser displays:
'; foreach ($array as $value) { $html .= '
$value
'; } $html .= ''; return $html; } ?>
Here is my code:
<html>
<head>
<title>test</title>
<?php
$cities = array( 'San Francisco', 'San Diego', 'Los Angeles');
function createDropDown($name, $array) {
$html = '<select name=$name>';
foreach ($array as $value) {
$html .= '<option value="$value">$value</option>';
}
$html .= '</select>';
return $html;
}
?>
</head>
<body>
<form>
<?php
createDropDown("cities", $cities);
?>
</form>
</body>
</html>