save var_dump into text file
<p>I have the php code for sql query </p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?
$server = "127.0.0.1";
$username = "root";
$password = "1";

$link= connecttodb($server,$username,$password);

function connecttodb($server,$username,$password)
{

    $rez=fopen("test.txt","ab");
    if ($link=mysql_connect ("$server","$username","$password",TRUE))
    {
        fwrite($rez,"".$server." \r\n");
     echo "Connected successfully to &gt;&gt; " .$server ;
  
  $result = mysql_query('SHOW DATABASES');
        echo "&lt;br&gt;";
        while ($row = mysql_fetch_array($result))
        {
            var_dump ($row); }
     }
    }
    ini_set('max_execution_time', 10);
    return $link;
?&gt;</code></pre>
</div>
</div>
</p>

<p>this code print my database name on the browser
how I can save the database name into text file</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>Connected successfully to &gt;&gt; 127.0.0.1
array(2) { [0]=&gt; string(18) "information_schema" ["Database"]=&gt; string(18) "information_schema" } array(2) { [0]=&gt; string(2) "db" ["Database"]=&gt; string(2) "db" } array(2) { [0]=&gt; string(5) "mysql" ["Database"]=&gt; string(5) "mysql" } array(2) { [0]=&gt; string(10) "phpmyadmin" ["Database"]=&gt; string(10) "phpmyadmin" } array(2) { [0]=&gt; string(4) "test" ["Database"]=&gt; string(4) "test" }</code></pre>
</div>
</div>
</p>