If you change your code to this :
function selected($selectedno)
{
//for loop to loop through 10
$a = 11;
for ($i = 0; $i <10; $i++)
{
$a = --$a;
$num = $a;
if ($selectedno === $num)
{
$bash = ' selected="selected"';
}
echo '<option value='.$a.''.$bash.'>'.$a.'</option>'."\n";
$bash ='';
}
}
$number = 5;
selected($number);
It negates the need for a global variable.
BTW you have to reset the variable $bash to empty after each iteration to ensure that only one item is selected, and you dont need the double quotes around the item number.