本文整理匯總了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;
}