本文整理汇总了PHP中AviaHtmlHelper::create_select_option方法的典型用法代码示例。如果您正苦于以下问题:PHP AviaHtmlHelper::create_select_option方法的具体用法?PHP AviaHtmlHelper::create_select_option怎么用?PHP AviaHtmlHelper::create_select_option使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AviaHtmlHelper
的用法示例。
在下文中一共展示了AviaHtmlHelper::create_select_option方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_select_option
static function create_select_option($element, $entries, $fake_val, $parents, $level)
{
$output = "";
foreach ($entries as $key => $entry) {
if ($element['subtype'] == 'cat') {
if (isset($entry->term_id)) {
$id = $entry->term_id;
$title = $entry->name;
}
} else {
if (!is_array($element['subtype'])) {
$id = $entry->ID;
$title = $entry->post_title;
} else {
$id = $entry;
$title = $key;
}
}
if (!empty($title) || isset($title) && $title === 0) {
if (empty($fake_val)) {
$fake_val = $title;
}
$selected = "";
if ($element['std'] == $id || is_array($element['std']) && in_array($id, $element['std'])) {
$selected = "selected='selected'";
$fake_val = $title;
}
$indent = "";
for ($i = 0; $i < $level; $i++) {
$indent .= "- ";
}
if (strpos($title, 'option_group_') === 0) {
$output .= "<optgroup label='" . $id . "'>";
} else {
if (strpos($title, 'close_option_group_') === 0) {
$output .= "</optgroup>";
} else {
$output .= "<option {$selected} value='" . $id . "'>" . $indent . $title . "</option>";
}
}
if (!empty($parents) && !empty($parents[$id])) {
$level++;
$output .= AviaHtmlHelper::create_select_option($element, $parents[$id], $fake_val, $parents, $level);
$level--;
}
}
}
return $output;
}