What is the potential issue with calculating averages in PHP when dealing with dynamic tables?

When dealing with dynamic tables in PHP, the potential issue with calculating averages is that the number of columns may vary, making it difficult to accurately calculate the average for each row. One solution to this issue is to dynamically calculate the sum of values for each row and then divide by the total number of columns present in that row.

// Sample dynamic table data
$tableData = [
    [10, 20, 30],
    [15, 25],
    [5, 10, 15, 20],
];

// Calculate average for each row
foreach ($tableData as $row) {
    $sum = array_sum($row);
    $average = $sum / count($row);
    echo "Average: " . $average . "<br>";
}