I think what you would be better off doing is tackling the least common denominator first, so:
$number_1=rand(3,18);
$number_2=rand(1,6);
$number_3=rand(1,6);
if($number_2 >= 6)
{
$final_number_2 = $number_2 + $number_3;
}
else
{
$final_number_2 = $_number_2;
}
Then once you know the answer to that math, then concentrate on the major part:
if($number_1 >= 16)
{
$result = $number_1 + $final_number_2;
}
else
{
$result = $number_1;
}
The net result is that $result should hold the value your interested in.
Never be afraid to use intermediate variables when your working out complex math problems, and never be afraid to break your decision logic down in to smaller units, especially if it makes things easier to read.
You may want to take a look at the PHP builder articles section, where i'm currently doing a 10 part series on beginning PHP, part 6 from last week covered handling maths and numerical problems.
Cheers
Shawty