How can you iterate through an array of variables in PHP and output their values?

To iterate through an array of variables in PHP and output their values, you can use a foreach loop. This loop allows you to iterate through each element in the array and access its value. Within the loop, you can output the value of each variable using echo or print statements.

$variables = array('var1', 'var2', 'var3');

foreach ($variables as $variable) {
    echo $$variable . "<br>";
}