Calculating golf score against course par
The big thing worth mentioning here is:  Use an array for your scores.

The instant you do that, the code size shrinks dramatically.

$course = array(0, 4, 5, 4, 3, 5, 3, 4, 4, 4, 4, 4, 4, 4, 3, 5, 3, 4, 5);
$scores = array();

// $shots is your array of scores.  $shots[1] is the first hole, $shots[2] the second,
// etc.  If you remove the 0 at the beginning of `$course`, then $scores[0] will be
// the first, $scores[1] the second, etc, which is how arrays often look.  But with
// the zero, you can use the hole number as array index -- which might be more useful
// if these numbers are coming from an HTML form.

foreach ($course as $hole =&gt; $par) {
    if (!empty($shots[$hole])) {
        $scores[$hole] = $par - $shots[$hole];
    }
}

$scoresum = array_sum($scores);

if ($scoresum != 0) {
    $score = $scoresum;
}
else {
    $score = 'E';
}


But you could do even better than that, if you don't need those intermediate scores.

$course = array(0, 4, 5, 4, 3, 5, 3, 4, 4, 4, 4, 4, 4, 4, 3, 5, 3, 4, 5);
$score = 0;

foreach ($shots as $hole =&gt; $total) {
    if (!empty($total)) {
        $score += $course[$hole] - $total;
    }
}

if (empty($score)) $score = 'E';




And because this seems uncommon knowledge, and will simplify your life if these values are indeed from a form, you can get PHP to build your array for you by giving your inputs arrayish names.  Like so:

&lt;form&gt;
    &lt;input type="text" name="shots[1]"&gt;
    &lt;input type="text" name="shots[2]"&gt;
    &lt;input type="text" name="shots[3]"&gt;
    &lt;input type="text" name="shots[4]"&gt;
    &lt;input type="text" name="shots[5]"&gt;
 &lt;/form&gt;


(You can even leave out the index, if you don't mind the auto-number indexes PHP does.)

When this form is submitted, $_POST['shots'] will be an array of all the inputs.  Do something like:

$shots = array_map('intval', $_POST['shots']);


and you have an array containing the score entered for each hole (or 0 if the entered value didn't make sense as a number).