在PHP中禁用添加选项已禁用

时间:2017-03-11 19:08:11

标签: php arrays drop-down-menu

我在PHP中有一个带有下拉字段的表单,其中包含以下数组:

$field["options"] = array(
     array("value" => "Chişinău", "text" => "Chişinău", "depth" => 0),
     array("value" => "Bălţi", "text" => "Bălţi", "depth" => 0),
     array("value" => "Comrat", "text" => "Comrat", "depth" => 0),
     ...
     array("value" => "Ungheni", "text" => "Ungheni", "depth" => 0)
);

如何添加<option selected disabled>Choose one</option>作为第一个选项?

1 个答案:

答案 0 :(得分:2)

$field["options"] = array(
    array("value" => " ", "text" => "Choose one", "depth" => 0, "selected" => "selected", "disabled" => "disabled"),
    //...rest other option code
);