I have two foreach loops one contains the event list and one contains the values that have been selected by the user from the database.
Here is my code:
<select class="form-control select2-select" autocomplete="off" name="event[]" multiple>
<option value="">--Select--</option>
<?php
$variable= $editlist['evname'];
$array = explode(',', $variable);
foreach($evlist as $list){
foreach($array as $value){
?>
<option value="<?php echo $list->event ?>"<?php if($list->event==$value) echo "selected";?>><?php echo $list->event ?>
</option>
<?php
}
}
?>
</select>
$evlist contains:
array:9 [▼
0 => "3rd Edition Healthscape Summit India-2016"
1 => "6th Edition RESCOM Summit - Middle East"
2 => "8th Edition Hotelier Summit Middle East-2016"
3 => "Smart Education India-2016"
4 => "15th Edition Design Mission India-2016"
5 => "16th Edition Design Mission Africa-2016"
6 => "1st Edition India Industrial Summit 2016"
7 => "Pharmac India-2016"
8 => "17th Edition Design Mission Saudi Arabia-2016"
]
here $array contains only two values like:
Array (
[0] => Smart Education India-2016
[1] => 6th Edition RESCOM Summit - Middle East
)
And my output is as follows:
how to prevent the repeated values in the dropdown ?
