How can PHP code be optimized to improve readability and maintainability, as demonstrated in the code example?

Issue: To improve readability and maintainability of PHP code, it is essential to follow coding standards, use meaningful variable names, and break down complex logic into smaller, more manageable functions. Example:

// Original code
function calc($a, $b) {
    $c = $a + $b;
    $d = $c / 2;
    return $d;
}

// Improved code
function calculate_average($num1, $num2) {
    $sum = $num1 + $num2;
    $average = $sum / 2;
    return $average;
}