标签: php arrays multi-select dropdown
答案 0 :(得分:0)
您正在寻找in_array
in_array
if(in_array($category['ID'], $biz_cats)){ $selected = 'selected'; } else { $selected = ''; } echo '<option value="' . $category['ID'] . '" ' . $selected . '>' . $category['cat_name']</option>';