- explode: documentation ( source)
- array_diff: documentation ( source)
- range: documentation ( source)
<?php
$set_of_numbers = "1,2,4,5,9";
$numbers = explode(",", $set_of_numbers);
$range = range(1,12);
$numbers_to_output = array_diff($range, $numbers);
// [3,6,7,8,10,11,12]
foreach($numbers_to_output as $n){
echo '<option value='.$n.'>'.$n."</option>\n";
}