这些是存储在数组变量中的值。请有人告诉我如何在Dropdown中使用这些值?
$tasks = get_tasks();
$ tasks包含以下值
array(3) {
[0]=> array(2) { ["label"]=> string(0) "" ["value"]=> string(0) "" }
[1]=> array(2) { ["label"]=> string(20) "label1" ["value"]=> string(7) "value1" }
[2]=> array(2) { ["label"]=> string(23) "label2" ["value"]=> string(7) "value2" }
}
<select id="tasks" name="tasks">
<option value="" disabled="disabled" selected="selected"<?php _e('Select a task..') ?></option>
<?php
if(count($accounts) > 0) {
foreach ($tasks as $list) {
echo '<option value="' .$list['value']. '" '. (($saved_tasks == $list['value']) ? "selected" : "") . '>' .$list['label'] . '</option>';
}
}
else {
echo '<p>' . _e('No Tasks'. '</p>';
}
}
?>
</select>