Reputation: 14774
This is the HTML in a php file.
<select id="efHidden" style="width:80px;" class="text ui-widget-content ui-corner-all">
<option value="0">off</option>
<option value="1">on</option>
</select>
and I have a php variable $arr
having the required values to be shown
Upvotes: 0
Views: 3679
Reputation: 2449
<?php $arr = array('off' => 0, 'on' => 1); ?>
<select>
<?php
foreach($arr as $k => $v)
{
echo "<option value=\"$v\">$k</option>";
}
?>
</select>
Upvotes: 1
Reputation: 3785
<?php
$arr = array('0' => 'off', '1' => 'on');
?>
<select id="efHidden" style="width:80px;" class="text ui-widget-content ui-corner-all">
<?php foreach ($arr as $key=>$value) {?>
<option value="<?php echo $key; ?>"><?php echo $value; ?></option>
<?php } ?>
</select>
Upvotes: 1
Reputation:
$arr = array('1' => 'Option One', '2' => 'Option Two', '3' => 'Option Three');
foreach($arr as &$item){ echo '<option value="'.$item[0].'">'.$item[1].'</option>'; }
Upvotes: 0