How do I save the output of this code into a file? (PHP) : <p>This code that loops through some mysql tables:</p>

<pre><code>foreach($tables as $table)
{
echo "&lt;h2&gt;" . $table[0] . "&lt;/h2&gt;";
$query = "DESCRIBE " . $table[0];
$result = $mysqli-&gt;query($query);

$columns = $result-&gt;fetch_all();

foreach($columns as $column)
{
    echo $column[0]. '&lt;br /&gt;';
}
}
</code></pre>

<p>How do I make it output to a file? (Just the names of the tables and the column names)</p>
