How can nested loops or additional logic be used to improve the functionality of the PHP script in question?

The PHP script currently only outputs the multiplication table for a single number. To improve its functionality, nested loops can be used to generate the multiplication table for multiple numbers. By iterating through an array of numbers and using nested loops to calculate the products, the script can output a comprehensive multiplication table for all the specified numbers.

<?php
$numbers = [2, 3, 4, 5]; // Array of numbers for multiplication table

foreach ($numbers as $num) {
    echo "Multiplication table for $num: \n";
    for ($i = 1; $i <= 10; $i++) {
        echo "$num x $i = " . ($num * $i) . "\n";
    }
    echo "\n";
}
?>